PHP $_POST a drop down list

Discussion in 'PHP' started by AAZZ, May 23, 2009.

  1. #1
    Hello,

    My question is very simple. I normally get most answers off of google but this one i'm kind of stuck. I'm missing something really stupid.

    I make a page called 'index.php'. I create a list using the following code:
    
    <html>
    <head>
    <title>My Page</title>
    </head>
    <body>
    
    <form name="myform" action="list.php" method="POST">
      <select name="mydropdown">
        <option value="Milk">Fresh Milk</option>
        <option value="Cheese">Old Cheese</option>
        <option value="Bread">Hot Bread</option>
    </select>
    </form>
    
    </body>
    </html>
    
    Code (markup):
    OK, since I use a 'post' method, pointing this form to 'list.php'

    in 'list.php' now. Lets say I want to do something if the user picks 'Fresh Mild'. A different thing if the user picks 'Old Cheese' and etc...

    To be more precise, I want the browser to differenciate between which option was chosen from 'index.php' and save it in this page inside a variable.

    Let me know if i'm wrong:
    $save = $_POST['myform'];
    Code (markup):
    So, in other words. Whatever the user picks from the list from 'index.php', I want to send the information over to 'list.php' and save it in a variable.

    I hope this isn't too confusing.
    -Thanks in advance
     
    AAZZ, May 23, 2009 IP
  2. buldozerceto

    buldozerceto Active Member

    Messages:
    1,137
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    88
    #2
    Should be:
    $save = $_POST['mydropdown'];

    because the name of the drop down box is mydropdown.
     
    buldozerceto, May 23, 2009 IP
  3. AAZZ

    AAZZ Active Member

    Messages:
    1,612
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    90
    #3
    LMAO. Honestly, believe it or not, I just figuered it out and came here to appologize for posting for no reason.

    -Thanks anyways :)
     
    AAZZ, May 23, 2009 IP