i have a question.. i have a form in which a user adds his name, blood type and his age of birth.
at my sql table the column age_of_birth is type Date.
when i add a valid date, the date enters the table normally eg. 1990-02-21
when i add an invlaid date eg. 2000-50-50, the date enters the table like this 0000-00-00
i want to perform a check at the time the users presses the submit button.
a way, that i thought, to check was to do this:
You could do something like this to allow for many different date formats:
PHP Code:
$parsedDate = strtotime($_POST['date']); if($parsedDate == 0) { // returns zero if it cannot interpret it // handle invalid date input as desired } else { $dbCompatibleDate = date('Y-m-d', $parsedDate); } // then you can use $dbCompatibleDate in your SQL.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks