-
Notifications
You must be signed in to change notification settings - Fork 93
/
book.php
165 lines (153 loc) · 4.96 KB
/
book.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<html>
<head>
<link rel="stylesheet" href="main.css">
<script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
</head><?php include "dbconfig.php"; ?>
<script>
function getTown(val) {
$.ajax({
type: "POST",
url: "get_town.php",
data:'countryid='+val,
success: function(data){
$("#town-list").html(data);
}
});
}
function getClinic(val) {
$.ajax({
type: "POST",
url: "getclinic.php",
data:'townid='+val,
success: function(data){
$("#clinic-list").html(data);
}
});
}
function getDoctorday(val) {
$.ajax({
type: "POST",
url: "getdoctordaybooking.php",
data:'cid='+val,
success: function(data){
$("#doctor-list").html(data);
}
});
}
function getDay(val) {
var cidval=document.getElementById("clinic-list").value;
var didval=document.getElementById("doctor-list").value;
$.ajax({
type: "POST",
url: "getDay.php",
data:'date='+val+'&cidval='+cidval+'&didval='+didval,
success: function(data){
$("#datestatus").html(data);
}
});
}
</script>
<body style="background-image:url(images/bookback.jpg)">
<div class="header">
<ul>
<li style="float:left;border-right:none"><a href="ulogin.php" class="logo"><img src="images/cal.png" width="30px" height="30px"><strong> Skylabs </strong>Appointment Booking System</a></li>
<li><a href="book.php">Book Now</a></li>
<li><a href="ulogin.php">Home</a></li>
</ul>
</div>
<form action="book.php" method="post">
<div class="sucontainer" style="background-image:url(images/bookback.jpg)">
<label><b>Name:</b></label><br>
<input type="text" placeholder="Enter Full name of patient" name="fname" required><br>
<label><b>Gender</b></label><br>
<input type="radio" name="gender" value="female">Female
<input type="radio" name="gender" value="male">Male
<input type="radio" name="gender" value="other">Other<br><br>
<label style="font-size:20px" >City:</label><br>
<select name="city" id="city-list" class="demoInputBox" onChange="getTown(this.value);" style="width:100%;height:35px;border-radius:9px">
<option value="">Select City</option>
<?php
$sql1="SELECT distinct(city) FROM clinic";
$results=$conn->query($sql1);
while($rs=$results->fetch_assoc()) {
?>
<option value="<?php echo $rs["city"]; ?>"><?php echo $rs["city"]; ?></option>
<?php
}
?>
</select>
<br>
<label style="font-size:20px" >Town:</label><br>
<select id="town-list" name="Town" onChange="getClinic(this.value);" style="width:100%;height:35px;border-radius:9px">
<option value="">Select Town</option>
</select><br>
<label style="font-size:20px" >Clinic:</label><br>
<select id="clinic-list" name="Clinic" onChange="getDoctorday(this.value);" style="width:100%;height:35px;border-radius:9px">
<option value="">Select Clinic</option>
</select><br>
<label style="font-size:20px" >Doctor:</label><br>
<select id="doctor-list" name="Doctor" onChange="getDate(this.value);" style="width:100%;height:35px;border-radius:9px">
<option value="">Select Doctor</option>
</select><br>
<label><b>Date of Visit:</b></label><br>
<input type="date" name="dov" onChange="getDay(this.value);" min="<?php echo date('Y-m-d');?>" max="<?php echo date('Y-m-d',strtotime('+7 day'));?>" required><br><br>
<div id="datestatus"> </div>
<div class="container">
<button type="submit" style="position:center" name="submit" value="Submit">Submit</button>
</div>
<?php
session_start();
if(isset($_POST['submit']))
{
include 'dbconfig.php';
$fname=$_POST['fname'];
$gender=$_POST['gender'];
$username=$_SESSION['username'];
$cid=$_POST['Clinic'];
$did=$_POST['Doctor'];
$dov=$_POST['dov'];
$status="Booking Registered.Wait for the update";
$timestamp=date('Y-m-d H:i:s');
$sql = "INSERT INTO book (Username,Fname,Gender,CID,DID,DOV,Timestamp,Status) VALUES ('$username','$fname','$gender','$cid','$did','$dov','$timestamp','$status') ";
if(!empty($_POST['fname'])&&!empty($_POST['gender'])&&!empty($_SESSION['username'])&&!empty($_POST['Clinic'])&&!empty($_POST['Doctor']) && !empty($_POST['dov']))
{
$checkday = strtotime($dov);
$compareday = date("l", $checkday);
$flag=0;
require_once("dbconfig.php");
$query ="SELECT * FROM doctor_availability WHERE DID = '" .$did. "' AND CID='".$cid."'";
$results = $conn->query($query);
while($rs=$results->fetch_assoc())
{
if($rs["day"]==$compareday)
{
$flag++;
break;
}
}
if($flag==0)
{
echo "<h2>Select another date as Doctor Unavailable on ".$compareday."</h2>";
}
else
{
if (mysqli_query($conn, $sql))
{
echo "<h2>Booking successful!! Redirecting to home page....</h2>";
header( "Refresh:2; url=ulogin.php");
}
else
{
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
}
else
{
echo "Enter data properly!!!!";
}
}
?>
</form>
</body>
</html>