frijole Posted March 12, 2008 Share Posted March 12, 2008 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. Quote Link to comment Share on other sites More sharing options...
paul2463 Posted March 12, 2008 Share Posted March 12, 2008 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); ?> Quote Link to comment Share on other sites More sharing options...
soycharliente Posted March 12, 2008 Share Posted March 12, 2008 <?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. Quote Link to comment Share on other sites More sharing options...
haku Posted March 12, 2008 Share Posted March 12, 2008 To the OP: Yes, you are correct, assuming you set the 'method' in your form tag to be 'post'. If you set it to be 'get', then on the next page you will have a value of $_GET['video'] that will be equal to 'preview'. Quote Link to comment Share on other sites More sharing options...
frijole Posted March 13, 2008 Author Share Posted March 13, 2008 thanks haku, good clarification. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.