bluebyyou Posted February 21, 2008 Share Posted February 21, 2008 I am trying to check for blank fields from a form, but this hasn't been working. For some reason $blanks isn't being incremented. What am I doing wrong? <?php foreach($_POST as $value) { if (empty($value)){ $blanks++; } } if ($blanks > 0) { //execute code } ?> Quote Link to comment Share on other sites More sharing options...
dave420 Posted February 21, 2008 Share Posted February 21, 2008 Are you sure your $_POST variable is being filled correctly? I tried it and it works for me... Quote Link to comment Share on other sites More sharing options...
bluebyyou Posted February 21, 2008 Author Share Posted February 21, 2008 yeah i even did the print_r($_POST) to check, I have no idea what is happening. Quote Link to comment Share on other sites More sharing options...
bluebyyou Posted February 21, 2008 Author Share Posted February 21, 2008 I figured it out as soon as I submitted that reply...I should have been putting if ($blanks == 0){} instead of: if ($blanks > 0){} I was having my code execute if there was blanks, instead of executing if there were no blanks, thanks for your help and sorry for the waste of time. Quote Link to comment Share on other sites More sharing options...
dave420 Posted February 21, 2008 Share Posted February 21, 2008 That's cool! I was too busy trying to see why $blanks wasn't incrementing I'm glad you got it sorted. Quote Link to comment 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.