Jump to content

empty function help


spick

Recommended Posts

Hi, need a little help.  I have a form that enters data into a mysql database.  What I want is if the menu_name field is empty then it redirects back to the entry page and if it's not empty it redirects to a content page. 

 

I can't seem to get it to work, when I leave the field empty it stills enters the data to the database and redirects me to the content page.  i follow the lynda.com tutorials and the video example worked but mine didn't for some reason.  The codes are exactly the same except some variables.

 

any help is appreciated.

 

<?php
$errors=array();

//form validation
if(!isset($_POST['menu_name']) || empty($_POST['menu_name'])){
	$errors[]='menu_name';
}

if(!empty($errors)){
	redirect("new_subject.php");
}

?>
<?php
$menu_name = mysql_prep($_POST['menu_name']);
$position = mysql_prep($_POST['position']);
$visible = mysql_prep($_POST['visible']);
?>

Link to comment
https://forums.phpfreaks.com/topic/130820-empty-function-help/
Share on other sites

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.