Log in

View Full Version : php form select not working



jamiller
11-15-2007, 02:56 PM
So I'm building a rather simple contact form and everything is working correctly except my dropdowns.

HTML:


<select name="requestType">
<option value="default" selected="yes">Select a Request Type</option>
<option value="salesRep">Speak to a Sales Rep</option>
<option value="generalInfo">General Information</option>
</select>


I've only included this select because as I said, everything else on the form (simple inputs) are being passed and error checked successfully.

My question is how do I check to see if the default value has been selected, in my case it's "Select a Request Type" or a valid option like salesRep?

The form is posting to sendContact.php and from there I have:


$requestType = $_REQUEST['requestType'];

if($requestType == "default") {
header('Location: contact.php?sent=no');
}


If I include $requestType in the email that I send I get "Select a Request Type" rather than "default" so I even tried if($requestType == "Select a Request Type") but it still didn't work.

Anybody have any ideas? Thanks for any and all help!

Jeff

boogyman
11-15-2007, 04:08 PM
it shouldn't be giving you Select a Request Type as that is just the Human Render portion, and should be taken from the script...

Post the processing code script for this form element so we can help you troubleshoot
javascript and php both please.

jamiller
11-15-2007, 05:28 PM
Ok, I figured it out. All I had to do was put my if statement checking the option value near the bottom, I originally had it near the top.

Thanks anyways! And is it common for these things to have JavaScript? Because I don't.