Jump to content


Photo

Explode!


  • Please log in to reply
2 replies to this topic

#1 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 04 October 2006 - 09:19 PM

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.

<?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;
}
?>


#2 tleisher

tleisher
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 04 October 2006 - 09:22 PM

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

#3 Jocka

Jocka
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationDallas, Texas

Posted 04 October 2006 - 09:23 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users