I'm trying to send information to a PHP page, but it returns me a 404 error status.
<form name="registerForm" novalidate>
<div class="field"><label for="name">name : </label><input type="text" ng-model="register.registerInfo.name" name="name" id="name" autocomplete="off" required ></div>
<div class="field"><label for="number">number : </label><input type="text" ng-model="register.registerInfo.number" name="number" id="number" autocomplete="off" required ></div>
<br>
<button ng-click='registerForm.$valid && register.register()'>send</button>
</form>
A part of app.js, I'm using ngrouting
.controller('RegisterCtrl', ['$http', function($http){
this.registerInfo = {
name: '',
number: ''
};
this.register = function() {
var data = {
name: this.registerInfo.name,
number: this.registerInfo.number
};
$http.post('register.php', data).then(function(data) {
console.log(data);
}, function(error) {
console.error(error);
});
};
}]);
register.php
<?php
$data = json_decode(file_get_contents('php://input'));
echo 'slt';
echo $data->data->name;
http://puu.sh/m4FVO/3e607fd137.png
│ 404.html
│ favicon.ico
│ index.html
│ robots.txt
│
├───images
│ yeoman.png
│
├───scripts
│ │ app.js
│ │ connection.php
│ │ register.php
│ │
│ └───controllers
├───styles
│ main.css
│ style.css
│
└───views
contact.html
main.html
I want to send register information (the name and a number), analyze data in PHP and if they are okay save them with MySQL. I don't know why it can't find register.php since the path seems correct, maybe an issue with the server?