404我的js代码中的php文件出错
我构建了一个ionic应用程序[构建移动应用程序的angular js框架]。我使用php文件将用户添加到数据库中,但浏览器给我的php文件出现404错误 项目结构为“同一目录下的所有文件”404我的js代码中的php文件出错,php,angularjs,ionic-framework,server,Php,Angularjs,Ionic Framework,Server,我构建了一个ionic应用程序[构建移动应用程序的angular js框架]。我使用php文件将用户添加到数据库中,但浏览器给我的php文件出现404错误 项目结构为“同一目录下的所有文件” controllers.js[角度文件] signup.php connection.php 这是连接数据库的signup.php//connection.php <?php include("connection.php"); $data = json_decode(file_get_cont
- controllers.js[角度文件]
- signup.php
- connection.php
<?php
include("connection.php");
$data = json_decode(file_get_contents("php://input"));
$username = $data->username;
$password = $data->password;
$q = "INSERT INTO users (email, password) VALUES (:email, :password)";
$query = $db->prepare($q);
$execute = $query->execute(array(
":email" => $username,
":password" => sha1($password)
));
echo json_encode($username);
?>
更改php文件的目录无效
我需要一些帮助您是否有运行的web服务器(如Apache)可以为PHP提供服务?是的,我运行该服务器是为了为PHP提供服务,并且您是否确定位于您的服务器(127.0.0.1/index.html)而不是计算机(C:\Users\etc)上当你浏览网页时?是的,我确信它现在正在服务器上运行:)当你浏览到浏览器中的文件时,你也会得到404吗?
.controller('signUpCtrl', function($scope,$http,$state){
//variables
$scope.signUpInfo = {
userEmail: undefined,
password: undefined
}
// faunctions
$scope.signUpFunction = function(){
var data = {
userEmail: $scope.signUpInfo.userEmail,
password: $scope.signUpInfo.password
}
$http.post("signup.php", data).success(
function(response){
console.log(response);
console.log("sent");
$state.go("menu.home");
}).error(function(error){
console.error(error);
});
}
})