Results 1 to 3 of 3

Thread: php form select not working

  1. #1
    Join Date
    Jan 2007
    Location
    Charlotte, NC
    Posts
    82
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question php form select not working

    So I'm building a rather simple contact form and everything is working correctly except my dropdowns.

    HTML:
    HTML Code:
    <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:
    PHP Code:
    $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

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    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.

  3. #3
    Join Date
    Jan 2007
    Location
    Charlotte, NC
    Posts
    82
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •