-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproductupdate.php
95 lines (73 loc) · 2.85 KB
/
productupdate.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
<!--Pantelis Xiourouppas - 160056307 -->
<?php
session_start();
//disallows any and all access to this page UNLESS you sign in
include("connect.php");
include("functions.php");
if (!isset($_SESSION['id'])) {
header("Location:adminlogin.php");
}
$idCart = $_GET['idUpdateCart'];
$sql = "Select * from `products` where id=$idCart";
$result = mysqli_query($con, $sql);
$row = mysqli_fetch_assoc($result);
$name = $row['name'];
$price = $row['price'];
$image = $row['image'];
$information = $row['information'];
if (isset($_POST['UpdateButton'])) {
$name = $_POST['ItemName'];
$price = $_POST['ItemPrice'];
$image = $_POST['image'];
$information = $_POST['information'];
$sql = "update `products` set id=$idCart , name ='$name', price='$price', image='$image', information='$information' where id='$idCart'";
$result_run = mysqli_query($con, $sql);
if ($result) {
header('location:adminpage.php');
} else {
die(mysqli_error($con));
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Item Update</title>
<link href="css/style.css" rel="stylesheet">
<!-- This is the line you need -->
<link rel="icon" type="image/x-icon" href="images/favicon.ico">
<style>
img {
width: 200px;
}
</style>
</head>
<body>
<!-- Navigation Bar -->
<div class="navbar">
<a href="adminpage.php"><img src="images/Logo.png" class="logo"></a>
<ul>
<li><a href="user.php">Add User</a></li>
<li><a href="additem.php">Add Item</a></li>
<li><a href="adminpage.php">Database</a></li>
<li><a href="logout.php">Log Out</a></li>
</ul>
</div>
<!-- Input box -->
<div class="addingBox">
<form class="addingInputs" method="post">
<h1>Update Product id: <?php echo '' . $idCart . ''; ?></h1>
<input type="text-box" class="formInput" name="ItemName" autocomplete="off" value="<?php echo $name ?>">
<input type="text-box" class="formInput" name="ItemPrice" autocomplete="off" value="<?php echo $price ?>">
<textarea type="text-box" class="formInput" name="information" value="" style="height:100px"><?php echo $information ?></textarea>
<!-- way to print the image on screen so the admin can see what he is working with -->
<?php echo '<td> <img src="images/' . $image . '"/></d>'; ?>
<h2>Re-Upload Correct Image</h2>
<input type="file" name="image" id="file" autocomplete="off">
<button type="submit" class="submitButton" title="example.jpg" name="UpdateButton">Update</button>
</form>
</body>
</div>
</html>