Jump to content

what value does an html form button return?


frijole

Recommended Posts

I have a form and this is the HTML:

<input type="submit" name="video" value="preview">

 

so, this means, i think, that there will be a variable called $_POST['video'] and it will be set to the value of "preview"? or, will $_POST['video'] = "TRUE" or something else. I have been wondering about this for a while now and I can't seem to find an answer. Does anyone know? thanks.

set up two pages on your local testing server and try it out, one as the post page and the other with print_r($_POST) on it to tell you what information is passed across

 

sendit.php

<?php
$drinks= array (
'Spring Water'=>'7',
'Coke'=>'6',
'Coffee'=>'4',
'Tea'=>'5',
'Hot Chocolate'=>'8'
);
?>
<html>
<form action="checkit.php" method="post">
<?php
print "<tr><td>Select your drink</td><td><select name='drink'>";
foreach($drinks as $drink=>$price2)
{
print "<option value='$price2'>$drink - R $price2</option>";
}
print "</select>";
<input type="submit" name="Submit" value="Submit" />
</form>
</html>
<?php
?>

 

checkit.php

<?php
print_r($_POST);
?>

 

<?php
$drinks= array ('Spring Water'=>'7', 'Coke'=>'6', 'Coffee'=>'4', 'Tea'=>'5', 'Hot Chocolate'=>'8');
?>
<html>
<form action="checkit.php" method="post">
<?php
print "<tr><td>Select your drink</td><td><select name=\"drink\">";
foreach($drinks as $drink=>$price2)
{
print "<option value=\"$price2\">$drink - R $price2</option>";
}
print "</select>";
?>
<input type="submit" name="Submit" value="Submit" />
</form>
</html>

 

Your PHP tag at the bottom was off. Just letting you know.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.