hi
dears ,please help me below is a validation code that receive fields from a form
if(isset($_POST[‘submit’])){
$errors = array();
//form validation
// the loop is for the name of Fields that shouldnt be empty
// if there is an empty field then we put it into our errors array $
$required_fields = array(‘menu_name’, ‘position’, ‘visible’); // array contains the required fields
foreach($required_fields as $fieldname){
if(!isset($_POST[$fieldname]) || empty($_POST[$fieldname])&& $_POST[$fieldname] != 0){
// the $_POST[$fieldname] != 0 because we have radio input (visible) and we dont want the
$errors[] = $fieldname;
}
}
but it is not working i mean if i use only empty($_POST[$fieldname])it works for some fields but not were have true or false values like visible
please help