Jump to content

[SOLVED] checking for empty fields with foreach


bluebyyou

Recommended Posts

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
}
?>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.