-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_product.php
132 lines (100 loc) · 3.73 KB
/
edit_product.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
<?php
require_once('config.php');
if( $_SERVER['REQUEST_METHOD'] == "POST"){
$id = $_GET['id'];
$p_id = trim($_POST['p_id']);
$name = trim($_POST['name']);
$type = trim($_POST['product_type']);
$price = trim($_POST['price']);
$sql = " UPDATE product_data SET product_id= '$p_id' , product_name= ' $name', category = ' $type ' , price = ' $price ' WHERE product_id = '$id'";
$result = mysqli_query($conn, $sql);
if ($result){
header("location:product_data.php");
}
else{
echo "something went wrong" . mysqli_error($conn);
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Employee data</title>
<link href="css/cutomer_data.css" type="text/css" rel="stylesheet">
</head>
<body>
<style>
body {
background-color: rgb(218, 217, 238);
}
</style>
<h1>Edit Product Details</h1>
<header>
<nav class="navbar">
<ul>
<li><a href="logout.php"> <button class="logbtn">Log out</button></a></li>
<!-- <li><a href="login page.php"> <button class="logbtn">Log in</button></a></li> -->
<li><a href="offer_report.php" >Reports</a></li>
<li><a href="Admin FAQs.php" >FAQs</a></li>
<li><a href="product_data.php" class="active">Product Data</a></li>
<li><a href="employee_data.php">Employee Data</a></li>
<li><a href="A-offer.php">Offers</a></li>
<li><a href="admin page.php" >Home </a></li>
<img src="img/crm-icon-png.png" alt="logo">
</ul>
</nav>
</header>
<form method="post" id="form">
<div class="form-control">
<?php
require_once "config.php";
// $email = $_SESSION["username"];
$id = $_GET['id'];
$sql = "SELECT * FROM product_data WHERE product_id= '$id' ";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
?>
<label for="id" id="id">
Product Id
</label>
<!-- Input Type Email-->
<input type="text" id="id" name="p_id" value ="<?php echo $row['product_id']; ?>" />
<br>
<label for="name" id="name">
Product Name
</label>
<!-- Input Type Email-->
<input type="text" id="name" name="name" value ="<?php echo $row['product_name']; ?>" />
<br>
<label for="product_type" id="category">
Product Category
</label>
<select name="product_type" value ="<?php echo $row['category']; ?>">
<option value="Fashion">Fashion</option>
<option value="Mobiles and Tablets">Mobiles and Tablets</option>
<option value="Consumer Electronics">Consumer Electronics</option>
<option value="Books">Books</option>
<option value="Baby Products">Baby Products</option>
<option value="Groceries">Groceries</option>
</select>
<br>
<label for="price" id="price">
Product Price
</label>
<input type="number" id="price" name="price" value ="<?php echo $row['price']; ?>" />
<br>
<button type="submit" value="submit" name="submit">
Update
</button>
</div>
</form>
</body>
</html>
<?php
}
}
?>