I've looked at many posts on here and I still cant figure this out.
I am trying to verify that someone is older than 13 before they register for my site. This is what i have so far
<?php if (is_string($_POST['birthday']) && $_POST['birthday'] != 'mm/dd/yyyy') { $dateObj = new DateTime($_POST['birthday']); $ageLimit = new DateTime('13 years'); $now = new DateTime(date("Y/m/d")); $checkDate = $now->diff($ageLimit);; if($checkDate > $dateObj) { $errors[]='You must be atleast 13 years old to join.'; } else { $bday = mysqli_real_escape_string($db,$_POST['birthday']); } } else { $errors[]= 'Enter your birthday.'; } The code will always run to
$bday = mysqli_real_escape_string($db,$_POST['birthday']);} no matter what is entered in the date field and the outcome is always 1.
Can anyone help me with this? I cant figure this one out on my own.
<b>Birth Date</b><br><input type="date" name="birthday" value=<?php if(isset($_POST['birthday']))echo $_POST['birthday'];?>><br>