-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
146 lines (127 loc) · 4.7 KB
/
admin.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
<?php
session_start();
if(!isset($_SESSION['adminlogin']) || $_SESSION['adminlogin'] !==true)
{
header("location: admin/adminpanal.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Dashboard</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="name"><b>Product Name: </b></label>
<input type="text" name="productname" id="name" class="form-control" required autocomplete="off">
</div>
<div class="form-group">
<label for="mrp"><b>M.R.P: </b></label>
<input type="text" name="mrp" id="mrp" class="form-control" required autocomplete="off">
</div>
<div class="form-group">
<label for="price"><b>Price: </b></label>
<input type="text" name="price" id="price" class="form-control" required autocomplete="off">
</div>
<div class="form-group">
<label for="description"><b>Description: </b></label>
<input type="text" name="description" id="description" class="form-control" required autocomplete="off">
</div>
<div class="form-group">
<label for="file"><b>Images: </b></label>
<input type="file" name="file" id="file" class="form-control" required >
</div>
<div class="form-group" style="margin-top: 20px;">
<label for="category"><b>Category: </b></label>
<input type="text" name="category" id="category" class="form-control" required autocomplete="off">
</div>
<div class="form-group">
<label for="subcategory"><b>Subcategory: </b></label>
<input type="text" name="subcategory" id="subcategory" class="form-control">
</div>
<div class="form-group">
<label for="brand"><b>Brand: </b></label>
<input type="text" name="brand" id="brand" class="form-control">
</div>
<div class="form-group">
<label for="Quantity"><b>Quantity: </b></label>
<input type="number" name="quantity" id="quantity" class="form-control" max="100" autocomplete="off" required>
</div>
<br>
<div>
<input type="submit" name="submit" value="Upload" class="btn btn-success" >
</div>
</form>
</div>
<?php
require_once "config.php";
if (isset($_POST['submit']))
{
$name = $_POST['productname'];
$mrp = $_POST['mrp'];
$price = $_POST['price'];
$category = $_POST['category'];
$description = $_POST['description'];
$subcategory = $_POST['subcategory'];
$brand = $_POST['brand'];
$quantity = $_POST['quantity'];
$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 ='image/'.$filename;
move_uploaded_file($filetmp, $destinationfile);
$q = "INSERT INTO `products`(`image`, `productname`,`mrp`,`price` ,`description` ,`category`,`subcategory`,`brand`,`quantity` ) VALUES ('$destinationfile','$name','$mrp','$price','$description','$category','$subcategory','$brand','$quantity')";
$query = mysqli_query($conn , $q);
echo "<script>alert('Upload Successfully');</script>";
}
else{
echo "<script>alert('Upload Fill');</script>";
}
}
?>
</body>
</html>