I am using php to validate the age that user submit from a registration form. When i submits the form nothing happens, i just keep been redirected to the same page.
Here is my code behind
if(isset($_POST['register'])){
$dateOfBirth = $_POST['DOB'];
$today = date("Y-m-d");
$diff = date_diff(date_create($dateOfBirth), date_create($today));
if($diff->format('%y%') < 16){
die("you are too young to register");
}
No luck, I want to validate the DOB before it gets to the database so i need to validate the post variable but even when i try to echo the $_POST[‘register’], i am getting no output.
That is the point. Stop relying on those amaetur hacks and start using the correct way. The reason why you see nothing happening is because “register” doesn’t exist in the POST array. Therefore, you can’t even get pass a simple form submission checking. I have already given you the correct form submission checking above.
I’m guessing that is the case, on account of its use in the initial if clause.
But @spaceshiptrooper is correct in saying the request method should be tested instead of that.