客户登录系统后,他们希望通过日历预订课程。一旦他们点击要预订的课程,他们就会看到一个警告框,询问他们是否愿意预订课程。一旦他们点击确定,我希望这个用户拥有唯一的ID,并将该类存储到'class'数据库表中。我的classes.php文件中的代码是:
<script>
$(document).ready(function() {
var calendar = $('#calendar').fullCalendar({
//set edit to true
//editable:true,
header:{
//what to view
left:'prev,next',
center:'title',
right:''
},
events: 'load.php',
eventClick:function(event)
{
if(confirm("Are you sure you want to book this class?"))
{
var id = event.id;
$.ajax({
url:"book.php",
type:"POST",
data:{title:title, start:start, end:end, thisUser:thisUser},
success:function()
{
calendar.fullCalendar('refetchEvents');
alert("Event Booked");
}
})
}
},
});
});
</script>
在“book.php”文件中预订课程的代码是:
if(isset($_POST["title"]))
{
$query = "
INSERT INTO class
(title, start_event, end_event, cust_id)
VALUES (:title, :start_event, :end_event, :thisUser)
";
$statement = $connect->prepare($query);
$statement->execute(
array(
':title' => $_POST['title'],
':start_event' => $_POST['start'],
':end_event' => $_POST['end'],
':cust_id' => $_POST['thisUser']
)
);
}
我无法在我的数据库中存储任何内容。