Passing Values With Forms

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
JackD
Forum Commoner
Posts: 62
Joined: Sat Dec 12, 2009 6:25 pm

Passing Values With Forms

Post by JackD »

Is there a way to pass the value of a variable in $_POST? I have tried the following code:

$Pickup=4;
...
<form>
....
<input type=hidden name="OT" value=intval($Pickup)>
</form>

However, $_POST['OT'] is passed as "intval(\$Pickup". If I change the line to be:

<input type=hidden name="OT" value="$Pickup">

it passes "\$Pickup". If I leave off the double quotes, it passes the same value. Is there a way so it will pass the value 4?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Passing Values With Forms

Post by Christopher »

Code: Select all

<?php
$Pickup=4;
?>
<form action="mypage.php" method="post">
<input type=hidden name="OT" value="<?php echo intval($Pickup); ?>">
</form>
(#10850)
JackD
Forum Commoner
Posts: 62
Joined: Sat Dec 12, 2009 6:25 pm

Re: Passing Values With Forms

Post by JackD »

Thanks.... I knew there was something I was missing.
Post Reply