-
Notifications
You must be signed in to change notification settings - Fork 0
/
employee_edit_banner.php
101 lines (91 loc) · 3.91 KB
/
employee_edit_banner.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
<?php
include("includes/employee_session.php");
include_once("includes/database.php");
if (!isset($_GET['bannerid'])) {
die(header("location: employee_banner.php"));
}
$bannerid = mysqlidb::escape($_GET['bannerid']);
$error = "";
$success = "";
if (isset($_POST['Submit']) && isset($_POST['bannername']) && isset($_POST['bannerdesc']) && isset($_POST['bannerid'])) {
if (!empty($_POST['bannername']) && !empty($_POST['bannerdesc']) && !empty($_POST['bannerid'])) {
try {
$bannerName = mysqlidb::escape($_POST['bannername']);
$bannerDesc = mysqlidb::escape($_POST['bannerdesc']);
$bannerId = mysqlidb::escape($_POST['bannerid']);
$sql = "UPDATE banner SET BannerName='$bannerName', BannerDescription='$bannerDesc' WHERE BannerId=$bannerId";
mysqlidb::query($sql);
$success = "Successfully updated banner!";
} catch (\Throwable $th) {
$error = "Unknown error occured!";
}
} else {
$error = "Banner name or banner description must be filled up!";
}
}
$banner;
try {
$banner = mysqlidb::fetchRow("SELECT * FROM banner WHERE BannerId=$bannerid");
} catch (\Throwable $th) {
die(header("location: employee_banner.php"));
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" href="images/shirtlogo.png" type="image/x-icon">
<link href="styles/template.css" type="text/css" rel="stylesheet">
<link href="styles/pagetopbar.css" type="text/css" rel="stylesheet">
<link href="styles/khor.css" type="text/css" rel="stylesheet">
<title>Edit Banner</title>
</head>
<body>
<!-- ----------------------------------- TOP-BAR ----------------------------------- -->
<?php include "includes/pagetopbaremployee.php" ?>
<!-- ----------------------------------- TOP-BAR ----------------------------------- -->
<div class="body-wrapper">
<div></div>
<!-- ----------------------------------- BODY ----------------------------------- -->
<div class="content-wrapper container">
<h1>Edit Banners</h1>
<div class="employee-wrapper p-2">
<?php include "includes/employee_sidenav.php"; ?>
<div>
<?php if (!empty($error)) {
echo "<div class=\"card-error\">$error</div>";
} else if (!empty($success)) {
echo "<div class=\"card-success\">$success</div>";
}
?>
<form action="<?php echo $_SERVER['PHP_SELF'] . "?bannerid=" . $bannerid; ?>" method="post">
<div class="form-input-group">
<label>Banner Image Preview</label>
<img class="employee-banner-image" src="<?php echo $banner["BannerImage"]; ?>" alt="" required>
</div>
<input type="hidden" name="bannerid" value="<?php echo $bannerid; ?>">
<div class="form-input-group">
<label for="bannername">Banner Header</label>
<input type="text" maxlength="140" name="bannername" id="bannername" value="<?php echo $banner["BannerName"]; ?>" required>
</div>
<div class="form-input-group">
<label for="bannerdesc">Banner Description</label>
<textarea name="bannerdesc" maxlength="250" id="bannerdesc" required><?php echo $banner["BannerDescription"]; ?></textarea>
</div>
<div class="form-input-group">
<input type="submit" value="Save" name="Submit">
</div>
</form>
</div>
</div>
</div>
<!-- ----------------------------------- BODY ----------------------------------- -->
<!-- ----------------------------------- FOOTER ----------------------------------- -->
<?php include "includes/footeremployee.html" ?>
<!-- -----------------------------------FOOTER----------------------------------- -->
</div>
</body>
<script src="scripts/main.js"></script>
<script src="scripts/employee_sidenav.js"></script>
</html>