$choice){ if(isset($_POST['departamento']) && ($_POST['departamento'] == $key)) $defaults['departamento'][$key] = 'selected="selected"'; else $defaults['departamento'][$choice] = ''; } foreach($choiceprior as $key => $choice){ if(isset($_POST['prioridad']) && ($_POST['prioridad'] == $key)) $defaults['prioridad'][$key] = 'selected="selected"'; else $defaults['prioridad'][$choice] = ''; } // print form print "
"; } // display error function showError($type, $errors){ if(isset($errors[$type])) print "{$errors[$type]}
"; } // validate data function validateForm(){ global $choices; // start validation and store errors $error = array(); // validate drop-down if(!(isset($_POST['departamento']) && (array_key_exists($_POST['departamento'], $choices)) && $_POST['departamento'] != 0)) $errors['departamento'] = 'Select a departamento'; // validate input if(!(isset($_POST['contact_nombre']) && (strlen($_POST['contact_nombre']) > 5))) $errors['contact_nombre'] = 'Insert a contact_nombre of at least 5 characters'; if(!(isset($_POST['contact_telefono']) && (strlen($_POST['contact_telefono']) > 5))) $errors['contact_telefono'] = 'Insert a contact_telefono of at least 5 characters'; if(!(isset($_POST['contact_email']) && (strlen($_POST['contact_email']) > 5))) $errors['contact_email'] = 'Insert a contact_email of at least 5 characters'; if(!(isset($_POST['contact_message']) && (strlen($_POST['contact_message']) > 5))) $errors['contact_message'] = 'Insert a contact_message of at least 5 characters'; return $errors; } ?>