I’m doing a date validation but it keeps giving me an error message
Notice: Undefined variable: parts in C:\xampp\htdocs\signup.php on line 15
if (empty($_POST['birthday']))
// the user's date of birth cannot be a null string
$errors[] = "You must supply a date of birth.";
else if (!strpos("^([0-9]{2})/([0-9]{2})/([0-9]{4})$", $_POST['birthday'], $parts))
// Check the format
$errors[] = "The date of birth is not a valid date in the " .
"format DD/MM/YYYY";
elseif (!checkdate($parts[2],$parts[1],$parts[3]))
$errors[] = "The date of birth is invalid. " .
"Please check that the month is between 1 and 12, " .
"and the day is valid for that month.";
elseif (intval($parts[3]) < 1890)
// Make sure that the user has a reasonable birth year
$errors[] = "You must be alive to use this service.";
I just answered something about this last night. You’re working way too hard!
PHP has many different validators already. Use the checkdate for validation instead of REGEX
Reference: http://php.net/manual/en/function.checkdate.php