I can't get variables from forms
-
For instance, I've got this form:
Choose an Option: Option 1 Option 2 Option 3 Option 4
And choseOption.php is like this: The form work fine but when I choose an option and submit it I get this The option selected was:'' It is supposed that variable $selectedOption is created implicitly but it does not print its value. As you can see, I'm starting in php and web programing, so I'm kind of lost. Any help would be appreciated and excuse my english. Regards Iván Cruz
-
For instance, I've got this form:
Choose an Option: Option 1 Option 2 Option 3 Option 4
And choseOption.php is like this: The form work fine but when I choose an option and submit it I get this The option selected was:'' It is supposed that variable $selectedOption is created implicitly but it does not print its value. As you can see, I'm starting in php and web programing, so I'm kind of lost. Any help would be appreciated and excuse my english. Regards Iván Cruz
blackhattrick wrote:
echo ("The option selected was: '$selectedOption'");
You can't get values from forms just like that. You need to get the value via the POST method:
$selectedOption = $_POST['selectedOption'];
echo ("The option selected was: '$selectedOption'");
?>That should work.
Kristian Sixhoej
"Failure is not an option" - Gene Kranz
-
For instance, I've got this form:
Choose an Option: Option 1 Option 2 Option 3 Option 4
And choseOption.php is like this: The form work fine but when I choose an option and submit it I get this The option selected was:'' It is supposed that variable $selectedOption is created implicitly but it does not print its value. As you can see, I'm starting in php and web programing, so I'm kind of lost. Any help would be appreciated and excuse my english. Regards Iván Cruz
See Predefined variables[^] for further information.
-
For instance, I've got this form:
Choose an Option: Option 1 Option 2 Option 3 Option 4
And choseOption.php is like this: The form work fine but when I choose an option and submit it I get this The option selected was:'' It is supposed that variable $selectedOption is created implicitly but it does not print its value. As you can see, I'm starting in php and web programing, so I'm kind of lost. Any help would be appreciated and excuse my english. Regards Iván Cruz
When you POST variables, they are encapsulated in a $_POST array. Each value can be called by its key or $_POST['name of field']. In your example, $_POST['selectedOption'] would contain an integer 1-4. For more information, you can take a look at: http://www.w3schools.com/php/php_post.asp[^] Good luck! Ranjit Viswakumar Professional Services Specialist rviswakumar@hostmysite.com HostMySite.com[^]