Reputation: 1674
I have a general question regarding file_get_contents('php://input')
. When this code applies to a <form>
that is submitted for processing, what is actually returned?
This is in regards to some code I'm trying to follow and understand. There is no problem with the code, it works fine. I'm just curious.
Javascipt handles a click function on a form button. The javascript code then calls a payment_ini.php
script, which has the file_get_contents('php://input')
:
// Retrieve JSON from POST body
$jsonStr = file_get_contents('php://input');
$jsonObj = json_decode($jsonStr);
Will $jsonObj
contain the names/values from the form that is being processed? If the form has fields for name
, email
, phone
, will they be in $jsonObj
?
I've tried adding some logging/printout code in dev mode, but it either causes errors or it wont show.
Thanks for helping me see through the cobwebs.
Upvotes: 0
Views: 156
Reputation: 1674
Doh! error_log("jsonStr: " . $jsonStr);
adds to my error_log
. It shows what is in in the file_get_contents('php://input')
Previously, I tried error_log("jsonObj: " . $jsonObj);
, which did not like the object.
Thanks for looking
Upvotes: 0