I am trying to set up an if statement so that if an email address is not entered, the validation will look to see if the "No email" box was set.
If the no email box is checked, the check will skip and go to the next check.
If an email address is entered in the form, it will skip the no email check.
Here is my code as follows: So far, this is not working correctly. If an email address is entered, no problem, but if I do not enter and email even if I check the no email box, it still errors and takes me back to the page. Any thoughts?
BTW, is there a can set it to go back one page instead of reloading the page as it will reset the radio buttons for mem_type and thus will lose the information.
Thanks!
if((!$first_name) || (!$last_name) || (!$mem_email_addr) || (!$mem_addr) || (!$mem_city) ||(!$mem_state) ||(!$mem_zip) ||(!$mem_country) ||(!$mem_type) ||(!$mem_directory)){
echo 'You did not submit the following required information! <BR><BR>';
if(!$first_name){
echo "<LI>First Name is a required field. Please enter it below.<BR>";
}
if(!$last_name){
echo "<LI>Last Name is a required field. Please enter it below.<BR>";
}
if((!$mem_email_addr) || (!$no_email)) {
echo "<LI>You must enter an email address or check the "No email" box.<BR>";
}
if(!$mem_addr){
echo "<LI>Street Address is a required field. Please enter it below.<BR>";
}
if(!$mem_city){
echo "<LI>City is a required field. Please enter it below.<BR>";
}
if(!$mem_state){
echo "<LI>State is a required field. Please enter it below.<BR>";
}
if(!$mem_zip){
echo "<LI>Zip/Postal Code is a required field. Please enter it below.<BR>";
}
if(!$mem_country){
echo "<LI>Country is a required field. Please enter it below.<BR>";
}
if(!$mem_type){
echo "<LI>Membership Type is a required field. Please enter it below.<BR>";
}
if(!$mem_directory){
echo "<LI>Membership Directory is a required field. Please enter it below.<BR>";
}
include 'join_form3.html'; // Show the form again!
/* End the error checking and if everything is ok, we'll move on to
creating the user account */
exit(); // if the error checking has failed, we'll exit the script!
}