How do you get data from a form which has a dropdown list? I have a list of books which my users could choose from (1 choice only), but I don't seem to be getting their selection.
You can use the POST type submission to gather variables from drop-down menus, such as $_POST['select_box_name_here'] when you process the form in PHP. Just make sure you specify values when making your options.
I did. I use $val = $_POST['books'] but nothing comes out. I think the problem lies in the page itself since I ran Live HTTP Headers and found out that all the variable is sending is an "x" regardless of the selection. Ever got that before?
<form action="bookchoice.php" method="post"> <select name="books" size="1"> <option value="book1">Book 1</option> <option value="book2">Book 2</option> <option value="book3">Book 3</option> </select> <input type="submit" value "Submit" name="submit" /> </form> HTML: bookchoice.php $books = $_POST['books']; echo "You have selected $books"; PHP: