-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbookappointment.php
More file actions
78 lines (67 loc) · 2.16 KB
/
bookappointment.php
File metadata and controls
78 lines (67 loc) · 2.16 KB
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
<?php
session_start();
include "db_conn.php";
if (isset($_POST['pname']) && isset($_POST['dname']) && isset($_POST['slot'])) {
function validate($data){
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$pname = validate($_POST['pname']);
$dname = validate($_POST['dname']);
$slot = validate($_POST['slot']);
if (empty($pname)) {
header("Location: doctorlist.php?error=User Name is required");
exit();
}
else if(empty($dname)){
header("Location: doctorlist.php?error=docname is required");
exit();
}
else if(empty($slot)){
header("Location: doctorlist.php?error=slot is empty");
exit();
}
else if(strlen(strval($slot)) < 12){
header("Location: doctorlist.php?error=slot is unavailable");
exit();
}
else{
$time=substr($slot,0,5);
$dayy=substr($slot,6,2);
$month=substr($slot,9,2);
$year=substr($slot,12,4);
$day=substr($slot,17,3);
$date=strval($year."-".$month."-".$dayy);
$sql = "SELECT * FROM allapoinments WHERE doctor_name='$dname' AND patient_name='$pname' AND day='$day' AND date='$date' AND time='$time'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) === 0)
{
$sql = "SELECT * FROM allapoinments WHERE doctor_name='$dname' AND date='$date' AND time='$time'";
$result = mysqli_query($conn, $sql);
$pcount=mysqli_num_rows($result) +1;
$sql = "SELECT patlimit FROM doctorlist WHERE name='$dname' ";
$result = mysqli_query($conn, $sql);
$plimit=mysqli_fetch_assoc($result);
if($plimit['patlimit']<$pcount){
header("Location: doctorlist.php?error=all slots booked");
exit();
}
$sql = "INSERT INTO allapoinments (doctor_name, patient_name, day, date, time, pat_count) VALUES ('$dname','$pname','$day','$date','$time','$pcount')";
//echo phpinfo();
$result = mysqli_query($conn, $sql);
header("Location: viewappointmentsdoc.php");
exit();
}
else{
header("Location: doctorlist.php?error=Already appointment exists");
exit();
}
}
}
else{
//header("Location: index.php?error=dnt know");
header("Location: doctorlist.php?error=slot is required");
exit();
}