我正在使用$ http.post()方法将数据发送到php-> then databse,但是$ http.post在本地主机上成功运行,但在实时服务器上却无法运行...
但是$ http.get()在实时服务器和本地主机上都可以正常工作。我可以使用$ http.get()从数据中填充数据。
有人可以帮我吗?
POST方法代码:Angular
$scope.registerUser = function(){
if($scope.terms == true){
**$http.post('../../dcr/php/registration.php',**
{
'regUserName' : $scope.regUserName,
'regDisplayName': $scope.regDisplayName,
'uType':$scope.uType,
'regPassword':$scope.regPassword,
'regUserEmail':$scope.regUserEmail,
'gender':$scope.gender,
'regMobile' : $scope.regMobile,
'regUserAltEmail':$scope.regUserAltEmail,
'regPhotoID':$scope.regPhotoID,
'regPhotoIDno':$scope.regPhotoIDno,
'regDesignation' : $scope.regDesignation
}).success(function(data,status,header,config){
console.log("inside success");
}).error(function(data,status,header,config,error){
console.log("error");
});
PHP code:
<?php
require 'connection.php';
header('Content-Type: application/json');
$data = json_decode(file_get_contents("php://input"),true);
$regDisplayName = mysql_real_escape_string($data['regDisplayName']);
$regUserName= mysql_real_escape_string($data['regUserName']);
$regPassword= mysql_real_escape_string($data['regPassword']);
$regUserEmail= mysql_real_escape_string($data['regUserEmail']);
$gender= mysql_real_escape_string($data['gender']);
$uType= mysql_real_escape_string($data['uType']);
$regMobile = mysql_real_escape_string($data['regMobile']);
$regUserAltEmail = mysql_real_escape_string($data['regUserAltEmail']);
$regPhotoID = mysql_real_escape_string($data['regPhotoID']);
$regPhotoIDno = mysql_real_escape_string($data['regPhotoIDno']);
$regDesignation = mysql_real_escape_string($data['regDesignation']);
$sql = "INSERT INTO employee (`name`, `uname`, `mobile`, `password`, `email`, `userType`,`gender`,`AlternateEmail`,`PhotoIDProof`,`PhotoIDno`,`designation`)
VALUES ('$regDisplayName', '$regUserName', '$regMobile','$regPassword', '$regUserEmail', '$uType','$gender','$regUserAltEmail','$regPhotoID','$regPhotoIDno','$regDesignation')";
mysqli_query($db,$sql) or die(mysql_error());
?>
答案 0 :(得分:0)
请注意,我研究了该错误,正如@ Script47所说,并且如屏幕截图所示,它是服务器内部错误。您提到您正在使用Godaddy作为您的虚拟主机。我认为问题可能是.htaccess文件配置错误或损坏,因此您需要检查该问题。
我有此链接,您可以检查以获得更多信息:Why am I getting a 500 Internal Server Error Message?