<table>
<tr>
<td>Date </td>
<td>
<select size="1" name="year">
<?php
$years1=range(date("Y"),2030);
foreach ($years1 as $value) {
echo '<option value="'.$value.'">'.$value.'</option>\n';
}
?>
</select>
<select size="1" name="month">
<?php
$months=range(1,12);
foreach ($months as $value) {
echo '<option value="'.$value.'">'.$value.'</option>\n';}
?>
</select>
<select size="1" name="date" >
<?php
$days=range(1,31);
foreach ($days as $value) {
echo '<option value="'.$value.'">'.$value.'</option>\n';
}
?>
</select>
</td>
</tr>
</table>
In this table, we have taken three select tags. In it, we created a PHP array using range() function. After that, we have assigned each value to option in foreach loop.
Now we will check for appropriate date format.
if(!checkdate($_POST['returnmonth'],$_POST['returndate'],$_POST['returnyear']))
{echo "<script>alert('Wrong date entered !')</script>";}
checkdate takes three parameters for a month, day, and year. The parameters should be provided in the order mentioned above. The function returns a boolean value either true or false.
Comments
Post a Comment
Please feel free to comment. I would love to hear feedback.