-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_status.php
51 lines (48 loc) · 1.86 KB
/
admin_status.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
<?php
session_start();
include('src/config.php');
if ($_SESSION['log'] && $_SESSION['log']['role'] == 'admin') {
if (isset($_POST['status'])) {
$status = $_POST['status'] == 'open' ? 'open' : 'closed';
$qry = mysqli_query($con, "UPDATE clinic_status SET status='$status', updated_at=NOW() WHERE id=1");
if ($qry) {
echo '<script>alert("Clinic status updated successfully."); window.location.href = "admin_status.php";</script>';
} else {
echo '<script>alert("Failed to update clinic status. Please try again.");</script>';
}
}
$result = mysqli_query($con, "SELECT status FROM clinic_status WHERE id=1");
$clinicStatus = mysqli_fetch_assoc($result)['status'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Admin Panel - Clinic Status</title>
<?php include('src/head.php') ?>
</head>
<body>
<?php include('src/header.php') ?>
<div class="container">
<h2>Change Clinic Status</h2>
<form method="post">
<div>
<label>Current Status: <b><?php echo ucfirst($clinicStatus); ?></b></label>
</div>
<div>
<label for="status">Set Status:</label>
<select id="status" name="status">
<option value="open" <?php if ($clinicStatus == 'open') echo 'selected'; ?>>Open</option>
<option value="closed" <?php if ($clinicStatus == 'closed') echo 'selected'; ?>>Closed</option>
</select>
</div>
<button type="submit">Update Status</button>
</form>
</div>
<?php include('src/incfooter.php') ?>
</body>
</html>
<?php
} else {
header('Location: signin.php');
}
?>