chrisuk Posted April 5, 2007 Share Posted April 5, 2007 I am having trouble with checking multiple boxes to make sure they have been filled in: i have tried both: <?php if (!isset($forename) || ($surname) || ($email)){ header("Location: adduser.php"); } ?> and <?php if (empty($forename) || ($surname) || ($email)){ header("Location: adduser.php"); } ?> to no avail. I even tried seperate if statements... basically if any one of the fields is filled in then it accepts the form, which is obviously not what I want! What am i doing wrong? thanks Link to comment https://forums.phpfreaks.com/topic/45700-validation-problems/ Share on other sites More sharing options...
jitesh Posted April 5, 2007 Share Posted April 5, 2007 <?php if (!isset($forename) || !isset($surname) || !isset($email)){ header("Location: adduser.php"); } ?> Link to comment https://forums.phpfreaks.com/topic/45700-validation-problems/#findComment-222005 Share on other sites More sharing options...
chrisuk Posted April 5, 2007 Author Share Posted April 5, 2007 this is odd - i realise my mistake but even with the above code, it will accept entry with blank fields rather confused :S i tried: <?php if (empty($forename) || empty($surname) || empty($email)){ header("Location: adduser.php"); } ?> this works if nothing is filled in but if only one is filled in, it will accept! ??? Link to comment https://forums.phpfreaks.com/topic/45700-validation-problems/#findComment-222015 Share on other sites More sharing options...
chrisuk Posted April 5, 2007 Author Share Posted April 5, 2007 never mind, went about it a slightly different way.... i put all the code in the folowing if statement: if (!empty($forename) && !empty($surname) && !empty($email)) { //perform add user actions } else { header ("Location: adduser.php"); } Link to comment https://forums.phpfreaks.com/topic/45700-validation-problems/#findComment-222022 Share on other sites More sharing options...
r-it Posted April 5, 2007 Share Posted April 5, 2007 you could hve used this as well if(!strlen($variable)) { //do watever } Link to comment https://forums.phpfreaks.com/topic/45700-validation-problems/#findComment-222033 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.