NameSilo

PHP Contact Form

Spaceship Spaceship
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.
AfternicAfternic
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
•••

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back