-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpost.php
149 lines (132 loc) · 3.2 KB
/
post.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
147
148
149
<?php
session_start();
$userName=$_SESSION['userName'];
if(!isset($_SESSION['userName']))
{
header("Location:login.php");
}
?>
<html>
<head>
<title>Update</title>
<style>
* {
box-sizing: border-box;
}
body {
font-family: Arial, Helvetica, sans-serif;
}
/* Style the header */
.header {
grid-area: header;
background-color: #E98C53;
padding: 30px;
text-align: center;
font-size: 35px;
}
/* The grid container */
.grid-container {
display: grid;
grid-template-areas:
'header header header header header header'
'left middle middle middle middle middle'
'footer footer footer footer footer footer';
/* grid-column-gap: 10px; - if you want gap between the columns */
}
.left,
.middle,
.right {
padding: 10px;
height: 400px; /* Should be removed. Only for demonstration */
overflow: scroll;
}
/* Style the left column */
.left {
grid-area: left;
}
/* Style the middle column */
.middle {
grid-area: middle;
}
/* Style the right column */
.right {
grid-area: right;
}
/* Style the footer */
.footer {
grid-area: footer;
background-color: #85C1E9;
padding: 10px;
text-align: center;
}
</style>
</head>
<body>
<div class="grid-container">
<div class="header">
<h2 style="color: #2E4053"; align="left">XCompany </h2>
</div>
<div class="left" style="background-color:#aaa;">
<ul>
<li><a href="nhome.php">Dashboard</a></li>
<li><a href="view.php?userName=<?php echo $userName; ?>">View Profile</a></li>
<li><a href="edit.php">Edit Profile</a></li>
<li><a href="changepic.php">Change Profile Picture</a></li>
<li><a href="changepass.php">Change Password</a></li>
<li><a href="logout.php">Logout</a></li>
</ul>
</div>
<div class="middle" style="background-color:#bbb;">
<fieldset align="center">
<legend>Update Product</legend>
<form action="<?php htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="POST">
<table align="center">
<tr>
<td>Name</td>
<td><input type="text" name="pname" value="<?php echo $_GET['pname'] ?>"></td>
</tr>
<tr>
<td>Description</td>
<td><input type="text" name="description" value="<?php echo $_GET['description'] ?>"></td>
</tr>
<tr>
<td>Quantity</td>
<td><input type="number" name="pquantity" value="<?php echo $_GET['pquantity'] ?>"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="addProduct" value="Edit"/></td>
</tr>
</table>
</form>
</fieldset>
</div>
</body>
</html>
<?php
if (isset($_POST['addProduct']))
{
$con=mysqli_connect("localhost","root","","testdb");
if(!$con)
{
die("Connection Error: ".mysqli_connect_error()."<br/>");
}
if (isset($userName))
{
$pid=$_GET['pid'];
$pname=$_POST['pname'];
$description=$_POST['description'];
$pquantity=$_POST['pquantity'];
$sql="UPDATE products SET pname='$pname',description='$description',pquantity='$pquantity' WHERE pid='$pid'";
if(mysqli_query($con,$sql))
{
header("Location:nhome.php");
}
else
{
echo "Error in updating: ".mysqli_error($con);
}
mysqli_close($con);
}
}
?>