I have a form in one file that I submit using method POST. In the file to the form action, I use $_SERVER['REQUEST_METHOD'] === 'POST'
, but doing a var dump of $_SERVER['REQUEST_METHOD']
shows 'GET'
.
Any idea how this could be happening? The form is within an iframe with src = 'targetfile.php?id=30'
so the code looks something like this:
<iframe src="targetfile.php?id=30">
<form method="post" action="targetfile.php" target="credit_results">
<input type="hidden"开发者_开发知识库 name="pid" id="hidden_pid" value="30" />
<input type="text" class="std_grey" name="first_name_info" id="first_name_info"/>
</form>
<iframe name="credit_results" id="credit_results" scrolling="no" frameborder="0" width="960" height="1200"></iframe>
</iframe>
Because targetfile.php is getting both GET and POST due to the fact that its posting back to itself and originally loaded with a GET query, I would recommend changing your php to check for specific $_POST variables instead of the REQUEST_METHOD
.
For debugging a var_dump( $_POST );
should show things are there.
For actual use
if( !isset( $_POST['varYouNeed'] )) die( 'Missing varYouNeed variable' );
change:
$_SERVER['REQUEST_METHOD'] === 'POST'
to
$_SERVER['REQUEST_METHOD'] == 'POST'
精彩评论