2012-06-01 134 views
0

我有最奇怪的问题。我使用Ajax请求将数据发送到php页面,该页面将详细信息保存在数据库中供进一步使用。PHP Post request not functioning

每个echo之后的注释是我得到的输出。

$name = $_POST['name']; 
$surname = $_POST['surname']; 
$message = $_POST['description']; 
//$date = $_POST['date']; 
$type = $_POST['request_type']; 

echo file_get_contents("php://input"); // name=John&surname=Doe&description=Testing&request_type=note 

date_default_timezone_set("Africa/Johannesburg"); 
$time = strtotime("now"); 

echo "NAME & SURNAME: " . $name . ' ' . $surname; // NAME & SURNAME: 

谁能告诉我,为什么它输出的正确的东西,当我echo file_get_contents("php://input");而不是其他地方?

我不知所措。它没有任何意义......

编辑1:回应JBTRND。

要确保你的一切,我做出正确的判罚,这里是AJAX请求:

$.ajax({ 
    type:'POST', 
    url:"local_code/form_accepted.php", 
    data:serialized, 
    success:function(response){ 
     $('#request_type').attr('disabled'); 
     $('#dialog').html(response); 
     $('#docSumbit').html(response); 
    } 
}); 

serialized$('#support').serialize();

+2

你是否在执行POST请求而不是GET请求?发布你的AJAX调用代码。 – jbrtrnd

+0

您可以添加提供信息的JavaScript代码吗? – Manuel

+0

@JBRTRND在正确的轨道上。这绝对看起来像一个get请求。确保你在javascript中发布。 – MetalFrog

回答

1

也许你通过$ _GET通过他们?