Hey
How would you validate a drop down menu using PHP. I know how to do it with Javascript
Cheers
Tom Evans
Hey
How would you validate a drop down menu using PHP. I know how to do it with Javascript
Cheers
Tom Evans
Last edited by gold2040; 05-30-2006 at 01:30 PM.
Assuming your dropdown is named "dropdown" and the form's method is "post"...
But... what do you want, specifically?PHP Code:<?php
if ($_POST['dropdown'] == "value1") {
//do stuff like:
echo "it works!";
}
else {
//do something else like:
echo "error";
}
?>
Lots can be done to verify....
At least that's a basic example.
php.net has lot of info about various php things if you want to learn... look up "form handling"...
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Hey
Cheers for that. I mean like you just have to select 1 option out the dropdown menu
Tom Evans
Well... hate to point out the obvious... but it's worthless to have a dropdown menu "choice" if one is required... it's like an election with one candidate
Anyway... the above will do what you want.
Just for the "do stuff" make it continue in your script, and for else use, maybe, die("error. please try again.");
die() stops the page from loading at that point and outputs the string in the parentheses. You can use html in there too, like a JS-based back link.
that's the basics... not sure what funtionality you want if it's right or if it's wrong.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Totally pointless, but makes people think they have some choice in the matter?it's like an election with one candidate
We've had those for decades.![]()
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
quite true.
also, I'm guessing this might be related to "do you accept these terms: yes/no", in which case it's totally valid.
still worth pointing out, though![]()
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Bookmarks