-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdatedata.php
37 lines (28 loc) · 946 Bytes
/
updatedata.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
<?php
include("connection.php");
$title = $imgurl = $count= $price= $desc=$id= "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$title = test_input($_POST["title"]);
$imgurl = test_input($_POST["imgurl"]);
$count = test_input($_POST["count"]);
$price = test_input($_POST["price"]);
$desc = test_input($_POST["content"]);
$id = test_input($_POST["id"]);
$sql="UPDATE `product` SET `pname`='".$title."',`price`= '".$price."',`pcount`='".$count."',`imgurl`='".$imgurl."',`disc`='".$desc."' WHERE `pid`='".$id."';";
echo $sql;
// $conn->query($sql);
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
header("location:admindashboard");
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>