function validateForm(&$errors) { global $username, $password, $rePassword; $errors = []; if (!validateRequired($username)) { $errors['username'][] = 'User Name is required'; } else { if (!validateLen($username, 4)) { $errors['username'][] = 'User Name must be at least 4 characters long'; } } if (!validateRequired($password)) { $errors['password'][] = 'Password is required'; } else { if (!validateLen($password, 5)) { $errors['password'][] = 'Password must be at least 5 characters long'; } if (!validateNonAlphaNumeric($password)) { $errors['password'][] = 'Password must contain at least 1 non alphanumeric character'; } if ($password !== $rePassword) { $errors['rePassword'][] = 'Password not match'; } } return empty($errors); }
function validateForm(&$errors) { global $username, $password, $confirm_password; $errors = []; if (!validateRequired($username)) { $errors['username'][] = 'Username is required'; } else { if (!validateLongerOrEqualString($username, 4)) { $errors['username'][] = 'Username must be at least 4 characters long'; } } if (!validateRequired($password)) { $errors['password'][] = 'Password is required'; } else { if (!validateLongerOrEqualString($password, 5)) { $errors['password'][] = 'Password must be at least 5 characters long'; } else { if (!validateNonAlphaNumeric($password)) { $errors['password'][] = 'Password must contain at least 1 non alphanumeric character'; } } } if ($confirm_password !== $password) { $errors['confirm_password'][] = 'Password and Confirm Password doesn\'t match'; } return empty($errors); }
function validateForm(&$errors) { global $firstName, $lastName, $username, $password, $gender, $formOfAddress; $errors = []; if (!validateRequired($firstName)) { $errors['firstName'][] = 'First Name is required'; } else { if (!validateLongerOrEqualString($firstName, 2)) { $errors['firstName'][] = 'First Name must be at least 2 characters long'; } } if (!validateRequired($lastName)) { $errors['lastName'][] = 'Last Name is required'; } else { if (!validateLongerOrEqualString($lastName, 2)) { $errors['lastName'][] = 'Last Name must be at least 2 characters long'; } } if (!validateRequired($username)) { $errors['username'][] = 'User Name is required'; } else { if (!validateLongerOrEqualString($username, 4)) { $errors['username'][] = 'User Name must be at least 4 characters long'; } } if (!validateRequired($password)) { $errors['password'][] = 'Password is required'; } else { if (!validateLongerOrEqualString($password, 5)) { $errors['password'][] = 'Password must be at least 5 characters long'; } if (!validateNonAlphaNumeric($password)) { $errors['password'][] = 'Password must contain at least 1 non alphanumeric character'; } } if (!validateRequired($gender)) { $errors['gender'][] = 'Gender is required'; } if (!validateRequired($formOfAddress)) { $errors['form_of_address'][] = 'Form Of Address is required'; } return empty($errors); }
function validateForm(&$errors) { global $username, $password, $confirmPassword; $errors = []; foreach (['username', 'password'] as $value) { if (!validateRequired(${$value})) { $errors[$value][] = "{$value} is required"; } if (!validateString(${$value})) { $errors[$value][] = "{$value} must be a string"; } } if (!validateRequired($confirmPassword)) { $errors['confirmPassword'][] = '"Confirm Password" is required'; } if (!validateString($confirmPassword)) { $errors['confirmPassword'][] = "\"Confirm Password\" must be a string"; } if (!validateLongerOrEqualString($username, 6)) { $errors['username'][] = "Username must be minimum 6 symbols long"; } if (!validateLongerOrEqualString($password, 8)) { $errors['password'][] = "Password must be minimum 6 symbols long"; } if (!validateNonAlphaNumeric($password)) { $errors['password'][] = 'Password must contain at least 1 non alphanumeric character'; } if (!validateLongerOrEqualString($confirmPassword, 8)) { $errors['confirmPassword'][] = "Password must be minimum 6 symbols long"; } if (!validateNonAlphaNumeric($confirmPassword)) { $errors['confirmPassword'][] = 'Password must contain at least 1 non alphanumeric character'; } if (strcmp($password, $confirmPassword) !== 0) { $errors['confirmPassword'][] = 'Confirm Password and Password must be equal'; } return empty($errors); }