Bird87 ZA
Bird87 ZA

Reputation: 2160

PHP Post request not functioning

I have the weirdest issue. I use an Ajax request to send data to a php page which saves details in a db for further use.

The comment after each echo is the output that I get.

$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: 

Can anyone tell me WHY it outputs the right stuff when I echo file_get_contents("php://input"); but not anywhere else?

I'm at a loss. It does not make sense what-so-ever...

EDIT 1: In response to JBTRND.

To ensure you all that I make the right call, here is the AJAX request:

$.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 is $('#support').serialize();

Upvotes: 0

Views: 138

Answers (1)

Lee Davis
Lee Davis

Reputation: 4756

Maybe your passing them via $_GET?

Upvotes: 1

Related Questions