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

Passing Values With Forms

Postby JackD » Mon Feb 08, 2010 9:37 pm

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

Re: Passing Values With Forms

Postby Christopher » Tue Feb 09, 2010 2:05 am

Syntax: [ Download ] [ Hide ]
<?php
$Pickup=4;
?>
<form action="mypage.php" method="post">
<input type=hidden name="OT" value="<?php echo intval($Pickup); ?>">
</form>
(#10850)
User avatar
Christopher
Site Administrator
 
Posts: 10512
Joined: Wed Aug 25, 2004 7:54 pm
Location: Portland, Oregon, US

Re: Passing Values With Forms

Postby JackD » Tue Feb 09, 2010 9:33 am

Thanks.... I knew there was something I was missing.
JackD
Forum Commoner
 
Posts: 58
Joined: Sat Dec 12, 2009 7:25 pm


Return to PHP - Code

Who is online

Users browsing this forum: bk6662, Google [Bot] and 1 guest