0

I have created a dynamic dropdown menu list which lists a column in a database. I can get that to show up fine but when I want to submit a result and POST that to another file all I get is an 'undefined' index error. Here is the last aprt of my index.php file.

   <select name="bob">
    <?php
        while($row = mysqli_fetch_assoc($result))
        {
        extract ($row);
        echo "<option value='$forename'>$forename</option>\n";
        }
            ?>
            </select>

        <form action='processnames.php' method='POST'>
        <input type='submit' value='Submit' />
        </form> </body> </html>

The processnames.php has the following code:

    Welcome <?php 
    session_start();
    echo $_POST["bob"]; ?><br />

Any help would be greatly appreciated. Thanks!

2 Answers 2

2

You need to put your select box inside the <form> tags:

    <form action='processnames.php' method='POST'>
    <select name="bob">
    <?php
    while($row = mysqli_fetch_assoc($result))
    {
      extract ($row);
      echo "<option value='$forename'>$forename</option>\n";
    }
    ?>
    </select>

    <input type='submit' value='Submit' />
    </form> </body> </html>
Sign up to request clarification or add additional context in comments.

Comments

1

The select tag needs to be in-between your form tags. Right now it's outside of your form.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.