-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_event.php
executable file
·132 lines (110 loc) · 4.11 KB
/
admin_event.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
<?php
error_reporting(0);
include "admin_header.php";
?>
<title>event</title>
<?php
$msg = "";
// If upload button is clicked ...
if (isset($_POST['submit'])) {
$filename = $_FILES["event_banner"]["name"];
$tempname = $_FILES["event_banner"]["tmp_name"];
$text = $_POST['des'];
$title = $_POST['title'];
$link = $_POST['link'];
$folder = "assets/images/event/".$filename;
if(!$db){
die("connection failed");
}
$msg= "connected successfully";
// Get all the submitted data from the form
$sql = "INSERT INTO event (title, event_banner, comment, registration) VALUES ('$title','$filename','$text','$link')";
// Execute query
mysqli_query($db, $sql);
// move the uploaded image into the folder: event
if (move_uploaded_file($tempname, $folder)) {
$msg = "Image uploaded successfully";
}else{
$msg = "Failed to upload image";
}
}
$result = mysqli_query($db, "SELECT * FROM image");
//delete row
if (isset($_POST['delete'])) {
$sql1 ="DELETE FROM event WHERE id = '{$_REQUEST['id']}'";
if(mysqli_query($db, $sql1)){
$msg= "record deleted successfully";
}
else{
$msg="Failed to delete record";
}
}
?>
<!--to avoid resubmission of form-->
<script>
if ( window.history.replaceState ) {
window.history.replaceState( null, null, window.location.href );
}
</script>
<!--custom css-->
<link rel="stylesheet" type="text/css" href="assets/css/admin_notice_event.css">
<div class="container-fluid">
<div class="row">
<!--form start-->
<div class="col-12 col-lg-3 order-lg-2">
<form class="form-container" method="post" action="admin_event.php" enctype="multipart/form-data">
<input type="hidden" name="size" value="1000000">
<div class="form-group">
<label>Title</label>
<input type="text" name="title" class="form-control" placeholder="Event title" required>
</div>
<div class="form-group">
<label>Upload Event Banner</label>
<input type="file" name="event_banner" class="form-control-file" required>
</div>
<div class="form-group">
<label>Registration Link</label>
<input type="url" name="link" class="form-control" placeholder="link" required>
</div>
<div class="form-group">
<label>Description:</label>
<textarea class="form-control" name="des" rows="5" ></textarea>
</div>
<div class="form-group">
<input class="form-control" type="submit" name="submit" value="submit">
</div>
</form>
</div>
<!-------------preview------------------->
<div class="col-12 col-lg-9 order-lg-1">
<div class="preview">
<?PHP
$sql2 = "SELECT * FROM event ORDER BY id DESC";
$result1 = mysqli_query($db, $sql2);
while($row = mysqli_fetch_array($result1)) {
echo "<div class='container'>";
echo "<div class='row' id='img'>";
echo"<div class='col-12 col-md-6'>";
echo '<form action="" method="POST" class="delete"><input type="hidden" name="id" value=' .$row['id']. '><input type="submit" name="delete" value= "Delete"></form>';
echo "<h1>".$row['title']."</h1>";
echo'<img class="myimg" src="assets/images/event/'.$row["event_banner"].'" onClick="modal(event)"/>';
echo'<div id="myModal" class="modal" style="padding:0px;">';
echo'<span class="close">×</span>';
echo'<img class="modal-content" id="img01" style="height:93vh; width:100%; margin-top:7vh; border:none;" />';
echo'</div>';
echo"</div>";
echo"<div class='col-12 col-md-6'>";
echo "<h1>Description:</h1>";
echo "<p>".$row['comment']."</p>";
echo"<a href=".$row['registration']." style='text-decoration:none; font-size:15px;'>Register here...</a>";
echo"</div>";
echo"</div>";
echo"</div>";
echo'<script src="assets/js/fullscreen.js"></script>';
}
?>
</div>
</div>
</div>
</div>
<script src="assets/js/fullscreen.js"></script>