Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

PHP Contact Form

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch

hoops

Established Member
Impact
0
I have this code in my contact form and it doesn't post correctly.

<label for="select-choice"></label>
<select id="selected" name="selected" class="select" value="test">
<option value="">General</option>
<option value="email 2">Service/Support</option>
<option value="email 3">Estimate/Quote</option>
</select>

Can anyone tell me the Post code for a drop down menu please?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
can you show the whole form so we can see where it fits in the form?

Also, for="" should contain the ID of the input it is the label for if you want to change that to be correct.
 
0
•••
Would be nice to have some more info hoops. The entire form code as pixelhero suggested would be nice.

And exactly how is it not posting correctly? Are there any values for $_POST['selected']?

Possible problems I can see is that you have given your drop-down a static value in the opening select tag (No need to give the select tag a value, if you want a default value to be set, simply add " selected" in one of the option tags), and I would also stay away from naming your drop-downs "selected", although this probably isn't an issue.

Here is an example of a working drop-down form (tested):
PHP:
<?php

	if(isset($_POST['dropdown']))
	{
	echo $_POST['dropdown'] ."<br />";
	}

?>
<form name="dropdowntest" method="post" action="test.php">
<select id="dropdown" name="dropdown">
<option value="email1" selected>General</option>
<option value="email2">Service/Support</option>
<option value="email3">Estimate/Quote</option>
</select>
<input type="submit" value="Submit" />
</form>
Note in the above, the first option contains " selected" in the opening tag, at the end, this specifies it as the default value.

Hope this helps,
Rhett.
 
0
•••
the SELECT tag should not have a value.
 
0
•••
is it so that the SELECT tag should not have any value..?
 
0
•••
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

New in Parking: updated way to act on many domains or inquiries at once
Your domain list and inquiry list now have a bar above and below the list. Check the items you want, then choose an action in the bar...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back