Validation

One of the main issues when receiving data from the user to verify their correctness. The checkdate () takes three arguments – respectively, month, day and year, the correctness of which is to be checked. The function returns a Boolean value TRUE if the date is correct task planning.


This function checks whether the year has a value between 1 and 32767, the month between 1 and 12 a day from one to the number of dependent of the month. They are taken into account leap years. In the following example, we checked the data provided by GET. To call test.php? Day = 12 & month = 10 & year = 1992 script displays „Data is correct” and for test.php? Day = 2 & month = 14 & year = 1980 – „Data is invalid.”

Example

<?php

if (checkdate ($_ GET [ ‚month’], $_ GET [ ‚day’], $_ GET [ ‚age’])) {
echo ‚date is incorrect’;
} else {
echo ‚date is incorrect’;
}

?>

Cookies help us deliver our services. By using our services, you agree to our use of cookies. More Info | Close