dazzclub Posted April 29, 2010 Share Posted April 29, 2010 Hi there, I'm working on a questionnaire and I need to ensure that the users cant proceed to the next page without selecting/completing a field. I need to check multiple variables as the path the user takes depends on the submitted questions. So I tried to use if(!isset($response_time_email || $effectivenes ){ but I keep getting stumped. Here is the original code; if(isset($_POST['submitted'])) { $response_time_email = $_POST['response_time_email']; //has radio been checked if(!isset($response_time_email)){ $fail = "<div id=\"fail\"><p>You must select a field before you proceed to the next page</p></div> "; }else{ if(isset($response_time_email)) { //$confirm = 'yes '.$contact_us.''; header('Location:page3.php'); } } } Any help would be great, thank you. Darren Link to comment https://forums.phpfreaks.com/topic/200159-check-to-see-if-several-variables-have-been-set/ Share on other sites More sharing options...
Ken2k7 Posted April 29, 2010 Share Posted April 29, 2010 if(!isset($response_time_email)){ That is always set in your context because the variable is set. It may be empty, but it's set. The check in the else case is stupid. It's either set or not. There's no need for the if statement inside the else. Link to comment https://forums.phpfreaks.com/topic/200159-check-to-see-if-several-variables-have-been-set/#findComment-1050506 Share on other sites More sharing options...
dazzclub Posted April 29, 2010 Author Share Posted April 29, 2010 Your right made sense, thank you. Here is the updated code; if(isset($_POST['submitted'])) { $recommend = $_POST['recommend']; //has radio been checked if($recommend == '') { $fail = "<div id=\"fail\"><p>You must select a field before you proceed to the next page</p></div> "; }else{ //$confirm = 'yes '.$contact_us.''; header('Location:page7.php'); } } Thank you Darren Link to comment https://forums.phpfreaks.com/topic/200159-check-to-see-if-several-variables-have-been-set/#findComment-1050530 Share on other sites More sharing options...
Ken2k7 Posted April 29, 2010 Share Posted April 29, 2010 empty Link to comment https://forums.phpfreaks.com/topic/200159-check-to-see-if-several-variables-have-been-set/#findComment-1050558 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.