Jump to content

Redirecting/Including If Array Value Not Set


phprocker

Recommended Posts

Hey all.  I have a form with inputs "menuitem[]" array.  Upon no user input to one of these fields I want to set a variable error and include the form generation page.

 

Is my following code a feasible way to do this?

 

foreach($_POST['menuitem'] as $value)
{
if(!isset($value) || $value == "")
{
 	$emptyvalue = TRUE;
}
}

if ($emptyvalue)
{
$erroralert = "You must fill in all the form fields! Please try again!";	
include "views/addmenus.php";
exit();
}

 

If works but just a bit unsure about it.

 

Cheers!

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.