Page 1 of 1

Accessing $_POST data, PHP 4.2.2 on Unix

Posted: Mon Nov 25, 2002 9:02 am
by Bill H
With the following code used to initiate the page:

Code: Select all

<?php
<form method=post action="archive.php?Doit=1">
<input type=image src="images/m_set.gif" name="Submit">
</form>
?>
Then how come (in archive.php):

Code: Select all

<?php
$Doing = 0 + $_POSTї'Doit'];                  // does not work
$Doing = 0 + $_REQUESTї'Doit'];            // does work
?>
I have no objection to using $_REQUEST, but would appreciate clarification of what is happening with the tramsmitted vars.

Posted: Mon Nov 25, 2002 9:07 am
by twigletmac
$_REQUEST works because you are accessing 'Doit' from the URL so it's being passed using get not post. Instead of $_REQUEST['Doit'] it would therefore be better to use $_GET['Doit']. 'Doit' would be passed using post if you did something like the following:

Code: Select all

<form method="post" action="archive.php"> 
<input type="hidden" name="Doit" value="1" />
<input type="image" src="images/m_set.gif" name="Submit"> 
</form>
Mac

Posted: Mon Nov 25, 2002 9:58 am
by Bill H
Aha. So the URL is always GET. Thanks, now I know more than I did.