Hello,
I implemented a javascript calendar into my script but i cant seem to extract the end user selection to save the selection into the database.
basically need to find a way to pass the calendar selection to a varialbe that php can understand.
<?php
include('connectionv2.php');
if(isset($_POST['btn_test']))
{ echo $_POST['hidden1'];
echo '<br />';
$db = Connection::getConnection();
try
{ $STH = $db->prepare("INSERT INTO tbl_servicerequest (projectexpire ) VALUES (:stamp )");
$STH->bindParam(':stamp', $_POST['hidden1']);
$STH->execute();
}
catch(PDOException $e) { echo 'ERROR: ' . $e->getMessage(); }
}
?>
<html>
<head>
<meta charset="utf-8" />
<title>jQuery UI Datepicker </title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery-ui-1.10.3/ui/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="jquery-ui-1.10.3/themes/base/jquery-ui.css" />
<script type="text/javascript">
$(document).ready(function(){
$("#date").datepicker({
showButtonPanel: true,
minDate: '0M',
maxDate: '+90D',
dateFormat: "d-MM-yy",
});
var dateString = $('#date').val();
var timestamp = Date.parse(dateString).getTime()/1000;
document.getElementById('#hidden1').value = timestamp;
});
</script>
</head>
<body>
<div>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="POST">
<p> Enter expire date: <br />
<input type="text" name="date" id="date"/></p>
<input type="hidden" name="hidden1" id="hidden1" />
<button type="submit" name="btn_test" value="">Test Button</button>
</form>
</div>
</body>
</html>