-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.php
157 lines (114 loc) · 4.74 KB
/
client.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
<?php
/* Main page with two forms: # and log in */
require 'php-modules/db.php';
session_start();
if(!$_SESSION['logged_in']){
$_SESSION['message'] = "You must log in first";
header("location: php-modules/error.php");
die;
}
//Share session_start on all pages
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="style-admin.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css">
<title>Clinic</title>
</head>
<body>
<div id="main-nav">
<nav id="menu" role="navigation">
<div class="brand">GC Clinic</div>
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="services.php">Services</a></li>
<li><a href="fee.php">Consultation Fees</a></li>
<li><a href="resource.php">Resources</a></li>
<li><a href="appointment.php">Appointments</a></li>
<li><a href="contact.php">Contact Us</a></li>
</ul>
</nav>
<div class="page-wrap">
<div id="menu-toggle">
<div class="hamburger-menu">
<div class="bar"></div>
</div>
</div>
<div class="nav-button button-toggle button-toggle2">
<?php require 'php-modules/buttons.php'; ?>
</div>
</div>
</div>
<form name="update_record" id="update_record" action="#" method="POST">
</form>
<?php
//Only show appointment to the client logged in
echo '</br><h2 style="text-align: center;">All Scheduled Appointments.</h2><hr></br>';
$email = $_SESSION['email'];
$query = "SELECT * FROM appointments WHERE email='$email'";
$result = @mysqli_query($mysqli, $query); // run query
if($result) { // if the query ran successfully
if(mysqli_num_rows($result)>0){
echo "<p style=\"text-align: center; color: red;\">* Click on <i class=\"fa fa-times\" aria-hidden=\"true\"></i> to cancel your Appointment.</p>";
echo "<table>
<tr>
<th>App_ID</th>
<th>Name</th>
<th>Phone</th>
<th>Email</th>
<th>Date</th>
<th>Time</th>
<th>Confirmation</th>
</tr>";
while($data = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>".$data['appNo'] . "</td>";
echo "<td>".$data['name'] . "</td>";
echo "<td>".$data['contactNum'] . "</td>";
echo "<td>".$data['email'] . "</td>";
echo "<td>".$data['date'] . "</td>";
echo "<td>".$data['time'] . "</td>";
echo "<td>".$data['confirm'] . "</td>";
$appNo = $data['appNo'];
if($data['confirm'] != "Cancelled")
{
echo "<td class=\"no_border\"><button id=\"update_app\" type=\"submit\" form=\"update_record\" value=\"$appNo\" name=\"update_app\"><i class=\"fa fa-times\" aria-hidden=\"true\"></i></button></td>";
}
echo "</tr>";
}
echo "</table>";
}
else{
echo "</br></br><p style=\"text-align: center;\">Error..! <br>No appointment scheduled yet.</p>";
}
}
else {
echo 'Error!<br>'.mysqli_error($mysqli);
}
if(isset($_POST['update_app']))
{
$update_app = trim($_POST['update_app']);
$app_query = "UPDATE appointments set confirm='Cancelled' WHERE appNo = $update_app";
$result = @mysqli_query($mysqli, $app_query); // run query
if($result)
{
$num = mysqli_affected_rows($mysqli);
if($num > 0)
header('location: client.php');
}
else {
echo 'Error!<br>'.mysqli_error($mysqli);
}
}
?>
<?php require 'php-modules/modal.php' ?>
<?php require 'php-modules/footer.php' ?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="js/main-js.js"></script>
</body>
</html>