Hello friends
i am validating date field......it is accepting character value in my form
$BIRTH_DATE=($_POST['BIRTH_DATE']);
$BIRTH_MONTH=($_POST['BIRTH_MONTH']);
$BIRTH_YEAR=($_POST['BIRTH_YEAR']);
$date_birth = $BIRTH_YEAR."/".$BIRTH_MONTH."/".$BIRTH_DATE;
if(!checkdate($BIRTH_MONTH,$BIRTH_DATE,$BIRTH_YEAR))
{
die ('ERROR: Enter a valid birth date, the format is yyyy/mm/dd');
}
when i am entring 200h/1g/2f ..........the form is accepting even this value
out put is:
current date: 2009/09/22
birth date: 19809/2UTC/309
please help me to validate it properly
function checkdate accepting character value?????
Moderator: General Moderators
-
om.bitsian
- Forum Commoner
- Posts: 36
- Joined: Wed Sep 09, 2009 4:13 am
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: function checkdate accepting character value?????
Use ctypeto validate your day, month and year values before calling checkdate().
And use selection lists in your form rather than text boxes... that way, you have more control over the day, month and year values that can be posted by normal users.... still validate with ctype and checkdate on the server though.
And use selection lists in your form rather than text boxes... that way, you have more control over the day, month and year values that can be posted by normal users.... still validate with ctype and checkdate on the server though.