-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuy.php
39 lines (30 loc) · 1.05 KB
/
buy.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
<?php
include("connection.php");
$title = $name = $pid= $price= $email= $phno="";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$title = test_input($_POST["title"]);
$price = test_input($_POST["price"]);
$id = test_input($_POST["id"]);
$name = test_input($_POST["name"]);
$email = test_input($_POST["email"]);
$phno = test_input($_POST["phno"]);
$sql="INSERT INTO `order` (`pid`, `pname`, `price`, `cname`, `email`, `phno`) VALUES ('".$id."','".$title."', '".$price."','".$name."', '".$email."','".$phno."');";
echo $sql;
// $conn->query($sql);
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
setcookie("pid",$id, time() + (86400 * 2), "/");
setcookie($id, "Sent order request for this product", time() + (86400 * 50), "/");
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
header("location:buyproduct");
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>