I have just written a Date Verification function for my form.
The date entered by the user in the for is the date on which they Bought a certain product.
Now The problems I'm having are the following:
1) I am using Language files, and I am unsure if I can use those globals withing a function.
2) What would be the best way for me to get specific error messages to the user.
3) Is there an easier way to do this, because it all seems a bit... farfetched.
Here is the code to my function:
(I also should mention that "ddMonth" is a global Array retrieved from the language file.)
function checkDate ($day, $month, $year){
// Februari
if ($month == $ddMonth[1]){
if ($day > 29){
return false;
} elseif ($day == 29){
// Check if the entered year is a leapyear
if ($year % 100 != 0 && ($year % 400 == 0 || $year % 4 == 0)){
return true;
} else {
return false;
}
} else {
return true;
}
}
// April
if ($month == $ddMonth[3]){
if ($day > 30){
return false;
} else {
return true;
}
// June
if ($month == $ddMonth[5]){
if ($day > 30){
return false;
} else {
return true;
}
// September
if ($month == $ddMonth[8]){
if ($day > 30){
return false;
} else {
return true;
}
// November
if ($month == $ddMonth[10]){
if ($day > 30){
return false;
} else {
return true;
}
}
}
Any help would be appreciated, thanks