Good day,
I am just a student working on his final year project.
I really need some help in executing a calendar dropdown by clicking on a calendar icon via an input.
I would require a Startdate and Enddate which will send the selected dates (dd/mm/yyyy) to the database
Appreciate if someone could guide me on the .js file and coding to make this work on Firefox and Chrome:
Below are my html codes:
<label> Start Date </label> <br> <br> <input class="form-control" type="text" name="startdate" value=<?=$startdate?> required > <label> End Date </label> <br> <br> <input class="form-control" type="text" name="enddate" value=<?=$enddate?> required > <div class="form-group"> <button class="btn btn-primary btn-block" type="submit" name="addprojbtn">Submit </button>
PHP codes:
if (isset($_POST['addprojbtn'])) { $projectname = $_POST['name']; $phpdate = strtotime( $_POST['startdate'] ); $startdate = date( 'd-M-Y', $phpdate); $phpdate = strtotime( $_POST['enddate'] ); $enddate = date('d-M-Y', $phpdate);
if($enddate < $startdate)
{
echo '<script type="application/javascript">alert("The End Date must not be earlier than the Start Date!");</script>';
} else {
if(mysql_query("INSERT INTO project(name, startdate, enddate, id) VALUES ('$projectname', STR_TO_DATE('$startdate','%d-%b-%Y'), STR_TO_DATE('$enddate','%d-%b-%Y'), '$id')"))
{
$redirectUrl = 'memberhome.php';
echo '<script type="application/javascript">alert("Project has been successfully Added! You will now be redirect back to member home page"); window.location.href = "'.$redirectUrl.'";</script>';
} else {
$redirectUrl = 'memberhome.php';
echo '<script type="application/javascript">alert("Project has failed to be added! You will now be redirect back to member home page"); window.location.href = "'.$redirectUrl.'";</script>';
}
}
}