-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddtemplates.php
205 lines (173 loc) · 6.34 KB
/
addtemplates.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php
include('config.php');
session_start();
if(!isset($_SESSION['USERNAME'])) {
header('location:index.php');
}
if(isset($_POST['add'])) {
$error = array();
$file_name = $_FILES['image']['name'];
$file_size = $_FILES['image']['size'];
$file_tmp = $_FILES['image']['tmp_name'];
$file_type = $_FILES['image']['type'];
$file_ext = end(explode('.',$file_name));
$extension = array("jpeg","jpg","png");
if(in_array($file_ext,$extension) === false) {
$error[] = "This file extension is not valid, please upload jpg or png file";
}
if($file_size>2097152) {
$error[] = "File size must be 2mb or Lower";
}
$file_nametemplate = $_FILES['template_name']['name'];
$file_sizetemplate = $_FILES['template_name']['size'];
$file_tmptemplate = $_FILES['template_name']['tmp_name'];
$file_typetemplate = $_FILES['template_name']['type'];
$file_exttemplate = end(explode('.',$file_nametemplate));
$extensiontemplate = array("zip","rar");
if(in_array($file_ext,$extension) === false) {
$error[] = "This file extension is not valid, please upload zip or rar file";
}
if($file_size>10097152) {
$error[] = "File size must be 10mb or Lower";
}
if(empty($error)=== true) {
move_uploaded_file($file_tmp,"images/".$file_name);
move_uploaded_file($file_tmptemplate,"templates/".$file_nametemplate);
} else {
echo"<pre>";
echo"print_r($error)";
echo"</pre>";
die();
}
$page = $_GET['TITLE'];
$title = $_POST['title'];
$sql = "INSERT INTO $page(IMAGE,TITLE,FILENAME) VALUES ('{$file_name}','{$title}','{$file_nametemplate}')";
$result = mysqli_query($conn,$sql) or die("Query not running");
header('location: users.php');
}
?>
<!doctype html>
<html lang="en">
<head>
<title>Admin Panel</title>
<link rel="stylesheet" type="text/css" href="mycss/file.css">
<script src="myjquery/jqueryfirst.js" type="text/javascript"></script>
<script src="myjquery/secondproper.js" type="text/javascript"></script>
<script src="myjquery/thirdbootstrap.js" type="text/javascript"></script>
<style>
body {
margin:0;
padding:0;
}
table {
width:100%;
}
th, tr {
border:1px solid white;
padding:8px;
text-align:center;
}
td {
background-color:#CCC;
padding:5px;
border:1px solid white;
text-align:center;
}
form {
padding-bottom:50px;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xl-12" style="height:auto;
background-color:#0F6">
<h2>Welcome To Admin Panel</h2>
<p style="color:#999">
<strong>Welcome Back <?php echo $_SESSION['USERNAME'];?></strong></p>
</div><!--welcome div -->
</div> <!-- row div -->
</div><!-- container -->
<nav class="navbar navbar-expand-lg navbar-light bg-dark navbar-dark">
<h4 class="navbar-brand" style="margin-top:6px">Admin Features:</h4>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle active" href="users.php"
id="navbarDropdown" role="button"
data-toggle="dropdown" aria-haspopup="true"aria-expanded="false">
Home
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="users.php">users</a>
<a class="dropdown-item" href="carousel.php">Carousel</a>
<a class="dropdown-item" href="homecard.php">Card</a>
<a class="dropdown-item" href="about.php">About Us</a>
<a class="dropdown-item" href="steps.php">Steps</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdown" role="button"
data-toggle="dropdown" aria-haspopup="true"aria-expanded="false">
Templates
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<?php
$sql2 = "SELECT TITLE FROM card";
$result2 = mysqli_query($conn,$sql2) or die("Template query not running");
if(mysqli_num_rows($result2)>0) {
while($row2 = mysqli_fetch_assoc($result2)) {
?>
<a class="dropdown-item " href="template.php?TITLE=<?php echo $row2['TITLE'];?>">
<?php echo $row2['TITLE'];?></a>
<?php } }
$page = $_GET['TITLE'];
?>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="feedback.php">Feedback</a>
</li>
</ul>
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="logout.php" style="color:white">Logout</a>
</li>
</ul>
</div>
</nav>
<!--ending of navbar -->
<div class="container-fluid">
<div class="row">
<div class="col-lg-10 col-md-10 col-sm-10 col-10">
<h2><?php echo "Add"." ".$page." "."Templates"; ?></h2>
</div>
</div><!-- row-->
<div align="center">
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" style="width:400px; text-align:
left" enctype="multipart/form-data">
<div class="form-group">
<input type="hidden" name="id" placeholder="Id of card" class="form-control" required>
</div>
<div class="form-group">
<label>Title *</label>
<input type="text" name="title" placeholder="Enter title Of Card" class="form-control" required>
</div>
<div class="form-group">
<label>Select Image *</label>
<input type="file" placeholder="Select Image" class="form-control-file" name="image" required>
</div>
<div class="form-group">
<label>Select File *</label>
<input type="file" placeholder="Select File" class="form-control-file" name="template_name" required>
</div>
<input type="submit" class="btn btn-primary" value="Add" name="add" required>
</form>
</div> <!-- align center div -->
</div> <!-- container fluid -->
</body>
</html>