As the title suggests, I am having difficulty finding a clean and elegant approach to both adding a working php function for a user's birthdate and setting an age limit to my birthdate form that I have created:
<div id="date1" class="datefield">
<input id="day" type="tel" maxlength="2" placeholder="DD"/> /
<input id="month" type="tel" maxlength="2" placeholder="MM"/> /
<input id="year" type="tel" maxlength="4" placeholder="YYYY" />
</div>
Here are the variables I have set up for the birthdate:
//initializing registration variables to prevent errors
$bday = ""; //birthday
$bday = date("Y-m-d");
In my database, the birth_date type is set as just a date. Is my setup correct so far? I understand that there may be a need to separate the date into month, day, and year, but all I am interested in is the valid year in which the user entered if I want to include conditions regarding the different number of days each month has.
Edit: With the paragraph that was just replaced, I realized that I am making this more complex than necessary. All I simply would like is for a php validation function that checks whether or not an inputted year is within the desired age specifications. So, on first code you see, I will be removing both day and month fields and only keep the year field.
Off tangent(but still relevant), should I not even bother to prompt users to inputting their DOB and instead have the required age limit documented in the terms/privacy policy(ies)? I know that even with a DOB form w/ restrictions not everyone will be willing to oblige to the rules ( ex. social net services like Facebook have 13 years as age limit but kids younger can work around that by lying; Twitter has their age limit documented rather than prompted).
Much advice would be greatly appreciated, thank you.