i have a form that asks for date input (field is date type in mysql). i want user to input date in YYYY-MM-DD format. if the input is wrong i want them to get a message saying "invalid date format" and nothing is updated on my database. how should i do this?
i tried:
if (!preg_match ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $_POST['mydate'])) {
but this translates the input into YYYY-MM-DD but they do not get any warning! when they input, say ghghgh it turns out to be 0000-00-00 on mysql and when they put 5-8-04 (meaning may 8, 2004) it turns out to be 2005-08-04!
help please!