-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdateproduct.php
More file actions
34 lines (27 loc) · 816 Bytes
/
updateproduct.php
File metadata and controls
34 lines (27 loc) · 816 Bytes
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
<?php
if(session_id() == '' || !isset($_SESSION)){session_start();}
if($_SESSION["type"]!="admin") {
header("location:index.php");
}
include 'config.php';
$id=$_POST["id"];
$aname = $_POST["aname"];
$genre = $_POST["genre"];
$artist = $_POST["artist"];
$year = $_POST["year"];
$qty = $_POST["qty"];
$price = $_POST["price"];
$image = $_POST["image"];
$result = $mysqli->query("SELECT * FROM products WHERE id =".$id);
if($result) {
while($obj = $result->fetch_object()) {
$update = $mysqli->query("UPDATE products SET name ='$aname', genre ='$genre' ,artist='$artist' ,year='$year' ,qty='$qty' ,image='$image' ,price='$price' WHERE id =".$id);
if($update)
echo 'Data Updated';
else
echo 'Failed';
echo $mysqli->error;
}
}
header ("location:products.php");
?>