我正在做一个约会计划系统。
因此,我每个小时有15分钟的时间段,并且在9:00 am、10:00am、11:00am、2:00pm、3:00pm、4:00pm时,我只会安排1名患者时隙。其余时间段将是2位患者。
如何用PHP编写代码?
以下是我为表格所做的代码:
<form method="POST" action="MAppointment.php">
Patient Name: <input type="text" name="name" class="form-control" required>
<br>
Phone Number: <input type="text" name="contact" class="form-control" required>
<br>
Appointment Date: <input type="date" name="date" class="form-control" onchange="AjaxFunctionForTime" required>
<br>
Appointment Time: <select name="time" class="btn1" id="time" required>
<option value="9:00">9:00am</option>
<option value="9:15">9:15am</option>
<option value="9:30">9:30am</option>
<option value="10:00">10:00am</option>
<option value="10:15">10:15am</option>
<option value="10:30">10:30am</option>
<option value="11:00">11:00am</option>
<option value="11:15">11:15am</option>
<option value="11:30">11:30am</option>
<option value="14:00">2:00pm</option>
<option value="14:15">2:15pm</option>
<option value="14:30">2:30pm</option>
<option value="15:00">3:00pm</option>
<option value="15:15">3:15pm</option>
<option value="15:30">3:30pm</option>
<option value="16:00">4:00pm</option>
<option value="16:15">4:15pm</option>
<option value="16:30">4:30pm</option>
<br>
<input type="submit" value="Book the Appointment">
这是 MAppointment.php
中的代码<?php
include('session.php');
$name=$_POST['name'];
$phoneNumber=$_POST['contact'];
$appointmentDate=$_POST['date'];
if(isset($_POST['time'])){
$appointmentTime=$_POST['time'];
mysqli_query($conn,"insert into appointment (name,contact,apptdate,appttime) values ('$name','$phoneNumber','$appointmentDate','$appointmentTime')");
$pid=mysqli_insert_id($conn);
}
?>
<script>
window.alert('Appointment booked successfully!');
window.history.back();
</script>
<?php
?>