Accessing $_POST data, PHP 4.2.2 on Unix

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Accessing $_POST data, PHP 4.2.2 on Unix

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post by Bill H »

Aha. So the URL is always GET. Thanks, now I know more than I did.
Post Reply