simple php if statement help

Soldato
Joined
25 Jan 2003
Posts
11,550
Location
Newark, Notts
i'm new to php, and I cant figure out how to do this if statement.

I've got a registration form and I'm trying to add validation to each of the inputs, but i'm stumped on the date of birth one. If users aren't 18 I need it to tell them that they cant register. What I came up with is below, and it doesn't seem to wanna work (probably cos its completely wrong :) ):

if ($year < 1988 and $month > 10) then;
echo "You must be 18 years of age to register";

How do i need to change it? apart from the actual maths regarding how it works out that they are 18 cos i know thats wrong already
 
Last edited:
cheers, i think that works. Although i just noticed that it should be > 1988 rather than less than, hehe. Cheers :)
 
nah still not working really as I want it to. At the moment if someone tries to register who were born in 2003 they dont get the message if they enter a month lower than 10. How can i change this to work properaly? :confused:

And how can i get this to work with the system date or something, because in a years time an 18 year old wouldn't be able to register based on the >1988 stuff in there at the moment
 
what do i need to put in there to alert the user on the page that they need to be 18? echo "blablabla"; im guessing, but where?
 
Cheers guys i think it works now :)

isset said:
I'm sure your tutor at Staffs uni would just love to see this thread ;)

Why's that? i'm being pointed in the right direction and trying to learn how to do something that we havn't been taught. I'm not going to learn php without someone/something explaining how things are done.
 
Back
Top Bottom