I'm building a site which requires the user to enter their date of birth as part of a form. Whem they click submit, the form is submit to a MySQL database.
One of the colums type (dob) is set as a date with PHPmyAdmin. I've got 3 fiels [DD] [MM] [YYY].
My issue is that if the user only enters 1 character in either the [DD] or [MM] field, this throws the date off completly in the database.
For example, if the user enters [01][02][2000] I recieve 2000-02-01 in my database. If the user enters [1][2][2000] I recieve 0000-20-12 in my database.
My question is, how can I check for this using some kind of validation to either prompt the user to add a 0 at the beginning - or - add the 0's on the backend if the form is not submit with them.
If someone supplies code, could they add comments explaining what each section does? Just trying to learn as I go.
Thanks a lot!
Jack