![]() |
Need Help with if than statements
Hi I'm trying to echo out some text when the user submits a form. My problem is i can't get an if statement to work for the option tag under the select tag. I played around with the value and name of the options with no luck.
Here is my code, all my other if statements work except this. if($SelectedOption == $_Post['tube']){ //selct option output echo "for your interest in Tube Men.<br>"; }else if($selectedOption == $_Post['oldtube']){ echo "for your interest in 70's Tube Men.<br>"; }else if($selectedOption == $_Post['dinosaur']){ echo "for your interest in Tube Dinosaur.<br>"; }else if($selectedOption == $_Post['gorilla']){ echo "for your interest in Tube Gorilla.<br>"; }else if($selectedOption == $_Post['spider']){ echo "for your interest in Tube Spiderman.<br>"; }else{ echo "for your interest in our products.<br>"; } Here is what im linking them to. <select name="product"> <option value="tube" name="1">Tube Man</option> <option value="oldtube" name="2">70's Tube Man</option> <option value="dinosaur" name="3">Tube Dinosaurs</option> <option value="gorilla" name="4">Tube Gorilla</option> <option value="spider" name="5">Tube Spiderman</option> </select> Thanks. |
Unlike functions, classes, namespaces, and insensitive created defined constants, PHP variables are ALWAYS case sensitive. There is no $_Post, the correct variable is $_POST.
Pull a switch on $_POST['product']. Option's I don't believe can be named if I recall my RFC's, so those would be ignored. The value(s) chosen will be under the $_POST['product'], so it would work well with a switch (PHP allows switches on strings since they are considered primitive data): PHP Code:
PHP Code:
|
how about using switch?
PHP Code:
Code:
<select name="some_name">and there's no 'name' property in <option> ----edit----- damn i was hoping to be first :D |
| All times are GMT +1. The time now is 03:00 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.