PHP server request method

I have a form in a single file, which I submit using the POST method. In the file for the form action I use $_SERVER['REQUEST_METHOD'] === 'POST', but the execution of the dump var $_SERVER['REQUEST_METHOD']shows 'GET'.

Any idea how this could happen? The form is inside the 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>
+5
source share
2 answers

Since targetfile.php receives both GET and POST due to the fact that its publication is back on its own and originally loaded using a GET request, I would recommend changing your php to check for specific $ _POST variables instead REQUEST_METHOD.

var_dump( $_POST ); , .

if( !isset( $_POST['varYouNeed'] )) die( 'Missing varYouNeed variable' );
+3

:

$_SERVER['REQUEST_METHOD'] === 'POST'

$_SERVER['REQUEST_METHOD'] == 'POST'
-2

All Articles