# PHP how to post from dropdown list



## DaLucky7

Hello all, I am trying to make a gift certificate that you can buy online for a business. Right now I have a form page that posts to a confirm page. So on the form page is input boxes for to from and billing address stuff. For the list of services the business has I created a drop down menu so that you can select the service you want. The problem I'm having is getting the service that you select to post on the confirm page. So I have a drop down menu like this:

<select id="serv" name="serv">
<option value="serv_1" id="serv_1" name="serv_1">Service 1</option>
<option value="serv_2" id="serv_2" name="serv_2">Service 2</option>
</select>

And I want to post the service to the description, and price.

So with an input box that looks like this: 

<input type="text" name="name" id="name" />

I set a code like this in PHP to write whatever they put in the box into the table on the confirm page:

echo $_POST['name'];

I thought that I could just write this for the drop down box and depending on what was selected I could fill out the description and price to how I want it. So something like:

if (isset($_POST['serv_1'])) {
echo "This is the First Service";
}

I also tried just saying:

if ($_POST['serv_1']) {
echo "This is the First Service";
}

I'm not even sure if anyone here can help me. I have an account here and I'm to lazy to set up one with a php site, but if worse comes to worse I will. This is a very simple problem mostly because I'm fairly new to PHP. If anyone could help or give me some feedback it would be greatly appreciated.


----------



## Laxer

I moved the thread to design....

I will answer it tonight when I have time, let me know if anything has changed since you posted.


----------



## Laxer

Ok here we go.....

Form:


HTML:


<form action=ACTION.php method=post>
	<select name="serv">
	<option value="1">Service 1</option>
	<option value="2">Service 2</option>
	</select>
	<input type=text name=id>
	<input type=submit value="Go">
</form>

php:


PHP:


<?
	$serv=$_POST['serv'];
	$id=$_POST['id'];
	echo 'You selected Service '.$serv.' with ID '.$id;
?>



To check what value you would so something like:


PHP:


if($serv=="1") echo 'selected service 1';

That make sense?


----------



## DaLucky7

Laxer said:


> I moved the thread to design....
> 
> I will answer it tonight when I have time, let me know if anything has changed since you posted.


Thank you I looked for a web design area but this forum setup is new to me so i just put it in programming which PHP is almost, but not what my question was lol. 

um i figureed out what i was doing but thanks for the input i'm sure it would work =]


----------



## Laxer

Thank you for letting me know, hopefully someone will find my post useful in the future.


----------

