-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadminlist.php
More file actions
101 lines (92 loc) · 4.1 KB
/
adminlist.php
File metadata and controls
101 lines (92 loc) · 4.1 KB
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
<html>
<head>
<title>Admin | DayOne Store</title>
<link rel='icon' href='favicon.ico' type='image/x-icon' />
<link href="bootstrap-5.0.2/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="main.css" rel="stylesheet" type="text/css">
</head>
<?php
session_start(); //starts the session
if($_SESSION['user'] && $_SESSION['usertype'] == 0){ //checks if user is logged in and admin
} else {
Print '<script>alert("You are not authorized to view this page!");</script>';
Print '<script>window.location.assign("home.php");</script>'; // redirects to login.php
}
$user = $_SESSION['user']; //assigns user value
$email = $_SESSION['email']; //assigns user value
?>
<body class="homebg">
<nav class="navbar navbar-dark bg-dark shadow">
<a class="navbar-brand" href="#" style="height:inherit;">
<img src="images/Store.png" class="navimgwht" height="40px">
</a>
</nav>
<div class="d-flex flex-row justify-content-center">
<div class="col-md-8 p-4 m-5 shadow-lg card moderncard">
<h4 align="center">Administrative Center</h4>
<h2 align="center" class="pb-2">Inventory List</h2>
<table border="1px" width="100%">
<tr>
<th>Id</th>
<th>Item</th>
<th>Description</th>
<th>Price</th>
<th>Image Name</th>
<th>Edit</th>
<th>Delete</th>
</tr>
<?php
$con = mysqli_connect("localhost", "id17778834_root", "-2JrCu|K*@hws%OX", "id17778834_dayonedb") or die(mysqli_error()); //Connect to server
$query = mysqli_query($con, "Select * FROM `items` ORDER BY 'id' ASC"); // SQL Query
$infostatus = "";
while($row = mysqli_fetch_array($query))
{
Print "<tr>";
Print '<td align="center">'. $row['id'] . "</td>";
Print '<td align="center">'. $row['item'] . "</td>";
Print '<td align="center">'. $row['description'] . "</td>";
Print '<td align="center">'. $row['price'] . "</td>";
Print '<td align="center">'. $row['img'] . "</td>";
Print '<td align="center"><a href="adminlistupdate.php?id='. $row['id'] .'"><img src="images/edit.svg" height="25px"></a> </td>';
Print '<td align="center"><a href="#" onclick="myFunction('.$row['id'].')"><img src="images/backspace.svg" height=25px></a> </td>';
Print "</tr>";
}
?>
</table>
</div>
<div class="col-lg-2">
<div class="card moderncard row p-4 mt-5 mb-4">
Welcome back Admin
<h2><?php Print "$user"?></h2>
<h5><?php Print "$email"?></h5>
<a href="logout.php">Click here to logout</a>
<a href="admin.php">Access admin options</a>
</div>
<div class="card moderncard row p-4 mt-n3">
<form action="additem.php" class="form-group" method="POST">
<h5>Add more to list </h5>
<label>Item</label>
<input type="text" class="form-control mb-2" name="item"></input>
<label>Description</label>
<input type="text" class="form-control mb-2" name="desc"></input>
<labe>Price</label>
<input type="number" class="form-control mb-2" name="price"></input>
<label>Image Link</label>
<input type="text" class="form-control mb-2" name="image"></input>
<input type="submit" class="btn btn-dark w-100 mt-4" value="Add to list"/>
</form>
</div>
</div>
</div>
<script>
function myFunction(id)
{
var r=confirm("Are you sure you want to delete this record?");
if (r==true)
{
window.location.assign("deleteitem.php?id=" + id);
}
}
</script>
</body>
</html>