Jump to content

Verify date exists


shank888

Recommended Posts

I am making a secure registration for my website and looking for a function that will verify with a user inputted date exists.

 

From my registration html form I am putting a month, day and year , each inputted separately into a single variable:

$bday = $year . "-" . $month . "-" . $day;

 

My birthday input looks like:

 

<div class=\"Container FormBoxLeft\">
  <b>Birthdate:</b>
</div>
<div class=\"Container FormBoxRight\">
  <select name=\"month\"><option value=\"\">-Month-</option>
  <option value=\"01\">January</option>
  <option value=\"02\">February</option>
  <option value=\"03\">March</option>
  <option value=\"04\">April</option>
  <option value=\"05\">May</option>
  <option value=\"06\">June</option>
  <option value=\"07\">July</option>
  <option value=\"08\">August</option>
  <option value=\"09\">September</option>
  <option value=\"10\">October</option>
  <option value=\"11\">November</option>
  <option value=\"12\">December</option>
  </select> 
<select name=\"day\">
<option value=\"\"> -Day-</option>';
//Print 31 Days
";
    for ($x=1; $x<=31; $x++) {
        echo "<option value='".$x."'"; if(isset($_POST['submit']) && $day == $x) { echo " selected"; } echo ">".$x."</option>\n";
    }
echo "</select> 
  <input name=\"year\" size=\"2\" maxlength=\"4\" type=\"text\">

 

So.. What I am asking is.. is there a secure way to check if the date the user inputted exists, or is there a better way to make the form more secure from that part.  Upon finding the users birthdate I am also wanting to check if the user is a certain age.

Link to comment
https://forums.phpfreaks.com/topic/253870-verify-date-exists/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.