php form variable.

Greetings,
how can i capture the choice that a user has selected from my drop down menu:

[php]

" New York London [/php]

i tried the following with no luck.
[php]Welcome <?php echo $_POST["menu"]; ?>[/php]

thanks

Well, first remove that hidden disabled option clause. It does nothing for you.

And, any select has one value assigned to it. The value of the selected item.

Like this: $menu_value=$_POST[“menu”];

That simple. Just note that it is the VALUE not the text displayed.

Oh, the code you showed should work if you remove that odd first menu option.
Also, you had an extra double-quote at the end of that first bad option, too…

you also have to send the data using (method=“post”) and the file of destination using (action=“file.php”) in form tag

[php]

"
New York
London

[/php]

Yes, Hanchan is correct. method=“get” is the default if not listed, so you really need to have that in place.
Thanks, Hanchan for pointing that out.

Here is a tutorial on forms and how they all work. Just click on the “Next-Chapter” links to look at
more on this subject. Might help you. http://www.w3schools.com/html/html_forms.asp

Sponsor our Newsletter | Privacy Policy | Terms of Service