What follows is part of a site registration script. This simplified/modifed part attempts to ensure the user filled in all fields in the XHTML form by checking whether all of the relevant variables have been set. The variables are passed using both get and post: <form action="filename?var=value" method="post"> (because I don't want the user's data in the URL but I want a certain variable to be passed whether the form is submitted or not).
I've double-checked my XHTML form and ensured that all of the <input name="x">s were all spelled the same as the $POST['x']s and that the <input>s have no default values. However, for some reason that I can't identify, even if I submit the form with no data in the text fields the variables are always evaluated as set. Am I using isset() incorrectly? Do I have a syntax problem? Could the $POST inside the $_GET cause a problem?
Here's the code:
<?php
switch ($_GET['var']) {
case "value1":
if(
(isset($_POST['email']))AND
(isset($_POST['email_conf']))AND
(isset($_POST['password']))AND
(isset($_POST['password_conf']))AND
(isset($_POST['first_name']))AND
(isset($_POST['last_name']))AND
(isset($_POST['bio']))
){
print("variables set!");
}else{
print("not all variables are set!");
}
break;
case "value2":
//do something different
break;
deafult:
//do something different
break;
}
?>
Thanks so much! 🙂