Jump to content

Archived

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

xyn

Explode!

Recommended Posts

Hey,
I have a date of birth, i want to check that when the user
enters their date of birth when they register it checks for
NN NN NNNN - No less that them exact values.

For security, when they want to change their password I
wanted them to TYPE their date of birth in, instead of
selecting from a drop down...

My code is completely ioff the track, so could someone
please help me? thanks.

[code=php:0]<?PHP
$str = "".$_POST[dob_d]."/".$_POST[dob_m]."/".$_POST[dob_y]."");
$dob = explode("/", $str);

for($dob[0]=0; $dob[0]>2){ //Check day
echo 'Enter a valid day, in your Date of birth.';
return false;
}

for($dob[1]=0; $dob[1]>2){ //check month
echo 'Enter a valid month, in your Date of birth.';
return false;
}

for($dob[2]=0; $dob[2]>4){ //check year
echo 'Enter a valid Year, in your Date of birth.';
return false;
}
?>[/code]

Share this post


Link to post
Share on other sites
Why not give them a drop down list? It's not any less secure, and it'll help you from having to code number limits... that way you dont get people entering their birthday is 99/99/9999

Share this post


Link to post
Share on other sites
well if they have to type it in then change the names.

dob_d, dob_m, dob_y
day, month, year

that way explode isn't needed. You can just use $_POST['dob_d'] m and y

Share this post


Link to post
Share on other sites

×

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.