Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.