-
Notifications
You must be signed in to change notification settings - Fork 0
/
addcategory.php
110 lines (91 loc) · 3.12 KB
/
addcategory.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
<?php
session_start();
if(!isset($_SESSION['adminlogin']) || $_SESSION['adminlogin'] !==true)
{
header("location: admin/adminpanal.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Add Category</title>
<link rel="stylesheet" type="text/css" href="css/admin.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>
<div class="navbar">
<h2>Dashboard</h2>
<nav>
<ul>
<li><a href="admin.php">Home</a></li>
<li><div class="dropdown">
<button class="dropbtn">Products</button>
<div class="dropdown-content text-center">
<a href="admin.php">Add Product</a>
<a href="addcategory.php">Add Category</a>
<a href="admin/manage_product.php">Manage Product</a>
</div>
</div></li>
<li><div class="dropdown">
<button class="dropbtn">Accounts</button>
<div class="dropdown-content text-center">
<a href="admin/adduser.php">Add User</a>
<a href="admin/deleteuser.php">Delete User</a>
</div>
</div></li>
<li><a href="admin/contact_request.php">Contact Request</a></li>
<li><a target="_blank" href="index.php">View Site</a></li>
<li><a href="admin/adminlogout.php">Logout</a></li>
</ul>
</nav>
</div>
<br><br>
<div class="col-lg-7 m-auto d-block">
<form action="" method="POST" enctype="multipart/form-data">
<div class="form-group">
<label for="cname"><b>Category Name: </b></label>
<input type="text" name="cname" id="name" class="form-control" required>
</div>
<div class="form-group">
<label for="file"><b>Images: </b></label>
<input type="file" name="file" id="file" class="form-control" required>
</div> <br>
<div>
<input type="submit" name="submit" value="Submit" class="btn btn-success" width="100vh">
</div>
</form>
</div>
<?php
require_once "config.php";
if (isset($_POST['submit']))
{
$name = $_POST['cname'];
$files = $_FILES['file'];
$filename =$files['name'];
$fileerror =$files['error'];
$filetmp = $files['tmp_name'];
$fileext = explode('.',$filename);
$filecheck = strtolower(end($fileext));
$fileextstored = array('png' , 'jpg' , 'jpeg');
if(in_array($filecheck,$fileextstored))
{
$destinationfile ='cimage/'.$filename;
move_uploaded_file($filetmp, $destinationfile);
$q = "INSERT INTO `cproducts`(`image`,`cname`) VALUES ('$destinationfile','$name')";
$query = mysqli_query($conn , $q);
echo "<script>alert('Upload Successfully');</script>";
}
else{
echo "<script>alert('Upload Fill');</script>";
}
}
?>
</body>
</html>