Trying to get a select button to output into a form email..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jerry101
    New Member
    • Jul 2008
    • 28

    Trying to get a select button to output into a form email..

    hi,

    i've got a form in which the user can fill out consisting of 2 text boxes to enter information in, a drop down box of choices and of course a submit button. when they fill it out, it sends the email of information to me fine. everything comes through apart from the option they've chosen from the drop down box.

    the code i have is the following;

    Code:
    <form action="mail.php" method="post">
    <input onfocus="this.select()" name="name" id="name" type="text" tabindex="1" value="name">
    <input onfocus="this.select()" name="phone" id="phone" type="text" tabindex="2" value="phone number" > 
     <br />
     <select name="time" id="time" value="time" size="1" tabindex="3">
        <option value="9">09:00</option>
        <option value="930">09:30</option>
        <option value="9">10:00</option>
        <option value="930">10:30</option>
        <option value="9">11:00</option>
        <option value="930">11:30</option>
        <option value="9">12:00</option>
        <option value="930">12:30</option>
        <option value="9">13:00</option>
        <option value="930">13:30</option>
        <option value="9">14:00</option>
        <option value="930">14:30</option>
        <option value="9">15:00</option>
        <option value="930">15:30</option>
        <option value="9">16:00</option>
        <option value="930">16:30</option>
        <option value="930">17:00</option>
      </select>
     <input name="submit" id="submit" type="submit" value="call me" tabindex="4">
    </form>
    and the php is

    Code:
    <?
    header("Location: thankyou.php"); 
    function checkOK($field)
    {
    if (eregi("\r",$field) || eregi("\n",$field)){
    die("Invalid Input!");
    }
    }
    
    
    $name=$_POST['name'];
    checkOK($name);
    $phone=$_POST['phone'];
    checkOK($phone);
    $time=$_POST['time'];
    checkOK($time);
    
    mail("my email address is here", 'Online Form: ', "\n\n Name -"."$name" ."\n\n Phone - "."$phone" "\n\n Time -"."$time");
    
    ?>

    Its obviously having troubles picking setting the variable for the drop down box, anyone know what im doing wrong?

    Thanks
    Last edited by eWish; Jul 31 '08, 01:02 PM. Reason: Please use code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Remove the value attribute for the select element. You also have only two values for the options unless that's intentional.

    Comment

    • jerry101
      New Member
      • Jul 2008
      • 28

      #3
      Thank you very much again!

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        No problem. Glad it's working.

        Comment

        Working...