-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBooking.php
197 lines (181 loc) · 6.37 KB
/
Booking.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?php session_start(); ?>
<html>
<head>
<link rel="stylesheet" href="main.css">
</head>
<?php include "DBconnect.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 CID=document.getElementById("clinic-list").value;
var DID=document.getElementById("doctor-list").value;
$.ajax
({
type: "POST",
url: "getDay.php",
data:'date='+val+'&cidval='+CID+'&didval='+DID,
success: function(data)
{
$("#datestatus").html(data);
}
});
}
</script>
<body style="background-image: url(Images/Pic12.jpg);">
<div class="header">
<ul>
<li style="float: left; border-right: none;"> <a href="Home.php" class="logo"> <img src="Images/Pic9.png" width="70px" height="60px"> <strong> WeCare </strong> Online Apppointment System </a> </li>
<li> <a href="Home.php"><strong> HOME </strong></a></li>
<li> <a href="Login.php"><strong> BACK </strong></a></li>
</ul>
</div>
<form action="Booking.php" method="post">
<div class="sucontainer" style="background-image:url(Images/Pic12.jpg)">
<label style="font-family:cursive;color:black"><b>Name:</b></label><br>
<input type="text" placeholder="Enter full name of patient" name="fname" required><br>
<label style="font-family:cursive;color:black"><b>Username:</b></label><br>
<input type="text" placeholder="Enter your username" name="username" required><br>
<label style="font-family:cursive;color:black"><b>Gender</b></label><br>
<input type="radio" name="gender" value="female" style="font-family:cursive;color:black">Female
<input type="radio" name="gender" value="male" style="font-family:cursive;color:black">Male
<input type="radio" name="gender" value="other" style="font-family:cursive;color:black">Other<br><br>
<label style="font-size:20px ;font-family:cursive;color:black">City:</label><br>
<select name="city" id="city-list" class="demoInputBox" onChange="getClinic(this.value);" style="width:100%;height:35px;border-radius:9px">
<option value="" style="font-family:cursive;color:black">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 ; font-family:cursive;color:black">Clinic:</label><br>
<select id="clinic-list" name="cid" onChange="getDoctorday(this.value);" style="width:100%;height:35px;border-radius:9px">
<option value="" style="font-family:cursive;color:black">Select Clinic</option>
<?php
$sql1="SELECT * FROM clinic";
$results=$conn->query($sql1);
while($rs=$results->fetch_assoc()) {
?>
<option value="<?php echo $rs["CID"]; ?>"><?php echo $rs["name"]; ?></option>
<?php
}
?>
</select><br>
<label style="font-size:20px ;font-family:cursive;color:black">Doctor:</label><br>
<select id="doctor-list" name="doctor" onChange="getDate(this.value);" style="width:100%;height:35px;border-radius:9px">
<option value="" style="font-family:cursive;color:black">Select Doctor</option>
<?php
$sql1="SELECT * FROM doctor";
$results=$conn->query($sql1);
while($rs=$results->fetch_assoc()) {
?>
<option value="<?php echo $rs["DID"]; ?>"><?php echo $rs["name"]; ?></option>
<?php
}
?>
</select><br>
<label style="font-family:cursive;color:black"><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" style="font-family:cursive;color:black">Submit</button>
</div>
<?php
if(isset($_POST['submit']))
{
include 'DBconnect.php';
$fname=$_POST['fname'];
$gender=$_POST['gender'];
$username=$_POST['username'];
$cid=$_POST['cid'];
$did=$_POST['doctor'];
$dov=$_POST['DOV'];
$status="Booking Registered.Wait for the update";
$timestamp=date('Y-m-d H:i:s');
$sql = "INSERT INTO booking (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($_POST['username'])&&!empty($_POST['cid'])&&!empty($_POST['doctor']) && !empty($_POST['DOV']))
{
$checkday = strtotime($dov);
$compareday = date("l", $checkday);
$flag=0;
require_once("DBconnect.php");
$query ="SELECT * FROM doctor_available 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!! </h2>";
header( "Refresh:2; url=Booking.php");
}
else
{
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
}
else
{
echo "Enter data properly!!!!";
}
}
?>
</form>
</body>
</html>