-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCategories.php
173 lines (160 loc) · 7.54 KB
/
Categories.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
<?php require_once("include/DB.php"); ?>
<?php require_once("include/Sessions.php"); ?>
<?php require_once("include/Functions.php"); ?>
<?php Confirm_Login(); ?>
<?php
if(isset($_POST["Submit"])){
$Category=$_POST["Category"];
date_default_timezone_set('Asia/Dubai');
$CurrentTime=time();
$DateTime=strftime("%d-%B-%Y %H:%M:%S",$CurrentTime);
$DateTime;
$Admin = $_SESSION["User-name"];
if(empty($Category)){
$_SESSION["ErrorMessage"]="Field must be field out";
Redirect_to("Categories.php");
}elseif(strlen($Category)>99) {
$_SESSION["ErrorMessage"]="Too long name for Category";
Redirect_to("Categories.php");
}else {
global $Connection;
$Query = "INSERT INTO category(datetime,name,creatorname) VALUES('$DateTime','$Category','$Admin')";
$Execute = mysqli_query($Connection,$Query);
if($Execute) {
$_SESSION["Successmessage"]="Category added Successfully";
Redirect_to("Categories.php");
}else {
$_SESSION["ErrorMessage"]="Category failed to add";
Redirect_to("Categories.php");
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/adminstyles.css">
<script src="js/all.js"></script>
<title>Categories</title>
</head>
<body>
<nav class="navbar navbar-inverse rounded-0" role="navigation">
<div class="container">
<div id="logo" class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#collapse">
<span class="sr-only">Toggle Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="Blog.php">
<img src="img/logo44.png" alt="apple" width=25%;>
</a>
</div>
<div class="collapse navbar-collapse" id="collapse">
<ul class="nav navbar-nav">
<li><a href="#">Home</a></li>
<li class="active"><a href="Blog.php">Blog</a></li>
<li><a href="">About Us</a></li>
<li><a href="">Services</a></li>
<li><a href="">Contact Us</a></li>
<li><a href="">Feature</a></li>
</ul>
<form action="Blog.php" class="navbar-form navbar-right">
<div class="form-group">
<input type="text" class="form-control" name="Search" placeholder="Search">
</div>
<button id="search_button" class="btn btn-info" name="SearchButton">Search</button>
</form>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-sm-2">
<img id="dashboard_logo" src="img/logo44.png" alt="logo">
<ul id="Side_Menu" class="nav nav-pills nav-stacked">
<li><a href="dashboard.php"><i class="fas fa-th"></i> Dashboard</a></li>
<li><a href="AddNewPost.php"><i class="fas fa-plus-square"></i> Add New Post</a></li>
<li class="active"><a href="Categories.php"><i class="fas fa-tags"></i> Categories</a></li>
<li><a href="Admins.php"><i class="fas fa-user"></i> Manage Admins</a></li>
<li><a href="Comments.php"><i class="fas fa-comment-alt"></i> Comments
<?php
global $Connection;
$AllCommnetQuery = "SELECT COUNT(*) FROM comments WHERE status='OFF'";
$AllCommnetExecute = mysqli_query($Connection,$AllCommnetQuery);
$AllCommnetrow=mysqli_fetch_array($AllCommnetExecute);
$AllCommnets=array_shift($AllCommnetrow);
if($AllCommnets>0) {
?>
<span class="label label-warning pull-right"><?php echo $AllCommnets; ?></span>
<?php } ?>
</a></li>
<li><a href="Blog.php?Page=1" target=_blank><i class="fas fa-podcast"></i> Live Blog</a></li>
<li><a href="Logout.php"><i class="fas fa-sign-out-alt"></i> Logout</a></li>
</ul>
</div> <!-- End Side Area-->
<div class="col-sm-10">
<h1>Manage Categories</h1>
<div><?php
echo message();
echo Successmessage();
?></div>
<div>
<form action="Categories.php" method="post">
<fieldset>
<div class="form-group">
<label for="categoryname"><span class="FieldInfo">Name:</span></label>
<input class="form-control" type="text" name="Category" id="categoryname" placeholder="Name">
</div>
<br>
<input class="btn btn-primary btn-block" type="submit" name="Submit" value="Add New Category">
</fieldset>
<br>
</form>
</div>
<div class="">
<table class="table table-striped table-hover">
<tr>
<th>Sr No.</th>
<th>Date & Time</th>
<th>Category Name</th>
<th>Creator Name</th>
<th>Action</th>
</tr>
<?php
global $Connection;
$ViewQuery = "SELECT * FROM category ORDER by id desc";
$Execute = mysqli_query($Connection,$ViewQuery);
$SrNo=0;
while ($row=mysqli_fetch_array($Execute)) {
$Id=$row["id"];
$DateTime=$row["datetime"];
$CategoryName=$row["name"];
$CreatorName=$row["creatorname"];
$SrNo++;
?>
<tr>
<td><?php echo $SrNo ?></td>
<td><?php echo $DateTime ?></td>
<td><?php echo $CategoryName ?></td>
<td><?php echo $CreatorName ?></td>
<td><a href="DeleteCategory.php?id=<?php echo $Id; ?>"><span class="btn btn-danger">Delete</span></a></td>
</tr>
<?php } ?>
</table>
</div>
</div> <!--END Main Area-->
</div> <!--END row-->
</div> <!--END Main Container-->
<div id="footer">
<p>Theme by Devstudio | ©2018-2019 | All rights reserved</p>
</div>
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>