...

View Full Version : form processing



andrewsheldon98
02-28-2003, 12:37 AM
how can i submit an option to a php form that brings up a particular sentence.

e.g
if option = 1 then print"you have selected option 1"
if option = 2 then print"you have selected option 2"
and so on.

this is the form im using
-------------------------------

<form action="eg.php" method="POST">
<select name="products">
<option>1
<option>2
<option>3
<option>4
</select>
<br>
<input type="submit" value="Go">
</form>

Phantom
02-28-2003, 12:44 AM
You may want this:

<option value=1>
<option value=2>
<option value=3>

etc..

The PHP script:


<?
if(isset($products)) {
if($products == '1') {
echo "You have selected Product 1<br>";
} elseif($products == '2') {
echo "You have selected Product 2<br>";
} elseif($products == '3') {
echo "You have selected Product 3<br>";
} elseif($products == '4') {
echo "You have selected Product 4<br>";
}
// and so on


Lemme know if this is what you need :)

andrewsheldon98
02-28-2003, 12:55 AM
cheers but ive just solved it.

i used option instead of product

<? if($option == 1){ ?>
<p>hello option 1</p>
<? } ?>
<? if($option == 2){ ?>
<p>hello option 2</p>
<? } ?>
<? if($option == 3){ ?>
<p>hello option 3</p>
<? } ?>

Phantom
02-28-2003, 12:59 AM
Never thought of that to work, but either way :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum