*This could be achieved simply by entering "type=\"hidden\"" in the HTML Attributes but this technique is worth demonstratin as it can come in useful every now and then.
Read this document if you want to know why it is so useful.
$date Exploded = explode("-", $date); //Our $date Exploded array should contain three elements. = 3) //For the sake of clarity, lets assign our array elements to //named variables (day, month, year).
$day = $date Exploded; $month = $date Exploded; $year = $date Exploded; //Finally, use PHP's checkdate function to make sure //that it is a valid date and that it actually occured. checkdate($month, $day, $year)) If you run the PHP code above, you’ll see that the final check results in an exception being thrown. Because the 31st of February, 2016, never actually occurred (the month of February will only have 29 days at most).
The date field could be a for a hotel booking or the user could be selecting their date of birth.
We now have a dynamic value on every form accessible to Java Script.
//For example purposes, I am using an invalid date.
$date = "2016-02-31"; //Firstly, we need to "break" the date up by using the explode function.
This is a tutorial on how to validate user-submitted dates using PHP.
In many cases, your users will have to select a date before submitting a web form.