PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
/**
* check a date in the Italian format
*/
function checkData($date)
{
if (!isset($date) || $date=="")
{
return false;
}
list($dd,$mm,$yy)=explode("/",$date);
if ($dd!="" && $mm!="" && $yy!="")
{
return checkdate($mm,$dd,$yy);
}
return false;
}
?>
Wrong. See this line: list($dd,$mm,$yy)=explode("/",$date);
It means the code will validate a date in the format: DD/MM/YYYY, you wanted: MM/DD/YYYY
Change this line to: list($mm,$dd,$yy)=explode("/",$date); unless you want to validate a date in the DD/MM/YYYY format.
also i forgot,
which mysql datatype for this date's input field i must declare for best result (is any "numeral" datatype in mysql) ?
my target is this input box to include only numbers and the right-slash (/) ..how can i achive this ?
Or you can just use the DATE type
And yes, there are many worries... how can you be sure that your users will type the date like MM/DD/YYYY ? how can you be sure they will be using / (slash) between the day, month and year?
Of course there are all the other security worries but this is beyond the scope of this topic...