Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何检索使用http.get发送的参数_Php_Angularjs_Web Services_Http - Fatal编程技术网

Php 如何检索使用http.get发送的参数

Php 如何检索使用http.get发送的参数,php,angularjs,web-services,http,Php,Angularjs,Web Services,Http,我正在使用http.get从数据库获取数据。我将参数与url一起发送。但无法从该url访问参数 以下是我的Angularjs控制器代码: app.controller('ListCtrl', ['$scope', '$http', '$location', '$window', function($scope,$http,$location,$window){ $scope.data = {}; $scope.getdata = function(){ $scope.datas = []

我正在使用http.get从数据库获取数据。我将参数与url一起发送。但无法从该url访问参数

以下是我的Angularjs控制器代码:

app.controller('ListCtrl', ['$scope', '$http', '$location', '$window', function($scope,$http,$location,$window){
$scope.data = {};
$scope.getdata = function(){
    $scope.datas = [];
    $http({
        url: "http://localhost/angular/data.php", 
        method: "GET",
        params: {'place':$scope.data.place,'pincode':$scope.data.pincode}
    })
    .success(function(data,status,headers,config){
        $scope.datas=data;
        console.log($scope.datas);
        $scope.navig('/show.html');
    })
    .error(function(){
         alert("failed");
    });
};
$scope.navig = function(url){
    $window.location.href = url;
};
}])
这是我的data.php文件


即使我输入了位置,它也会输出为“未输入位置”

这是检索数据的正确方法吗

我要经过一个地方或一个平码,不是两个都经过。这会引起什么问题吗


请帮忙。

解决了它。这是解决办法

我使用了这两行代码

$place = $_GET['place'];
$pincode= $_GET['pincode'];
而不是这4行代码,这4行代码实际上用于检索使用http.post发送的数据


您正在AJAX调用中使用GET,但希望通过
file\u GET\u contents(“php://input)
。选择其中一个。我是一个新手,我不知道如何获得这些参数。我应该使用什么来代替文件内容(“php://input") . 我必须使用GET not POST。要访问GET参数,请使用$\u GET global array而不是notphp://input 这是来自请求主体的输入。@RonDadon。谢谢使用$可以轻松解决此问题。
$place = $_GET['place'];
$pincode= $_GET['pincode'];
$postdata = file_get_contents("php://input");
$data= json_decode($postdata);
$place = mysql_real_escape_string($data->place);
$pincode = mysql_real_escape_string($data->pincode);