dadamssg Posted May 25, 2009 Share Posted May 25, 2009 im trying to run through each on of my four text fields to see if any are blank and then set an error message. i have this, but it instead of just having one error message, it sets four(the amount of text fields i have). how do i rearrange it to only set it once if any of the four are left empty? foreach($_POST as $field => $value) { if($value == "") $_SESSION['checkmail'] .= "<div class='blue'><center>Please fill in all blanks.</center></div>"; } Quote Link to comment https://forums.phpfreaks.com/topic/159533-solved-foreach-question/ Share on other sites More sharing options...
Ken2k7 Posted May 25, 2009 Share Posted May 25, 2009 foreach ($_POST as $field => $value) { if (empty($value)) { $_SESSION['checkmail'] = '<div class="blue"><center>Please fill in all blanks.</center></div>'; break; } } Or you can just remove your dot, but break preferably. Quote Link to comment https://forums.phpfreaks.com/topic/159533-solved-foreach-question/#findComment-841516 Share on other sites More sharing options...
dadamssg Posted May 25, 2009 Author Share Posted May 25, 2009 sweet thanks Quote Link to comment https://forums.phpfreaks.com/topic/159533-solved-foreach-question/#findComment-841517 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.