-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoeval.php
More file actions
44 lines (41 loc) · 1.2 KB
/
Copy pathnoeval.php
File metadata and controls
44 lines (41 loc) · 1.2 KB
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
<?php
session_start();
?>
<!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>Insertintodb</title>
<script src="js/addtocart.js"></script>
</head>
<body>
<?php
if(!isset($_SESSION["login"])){
header("refresh:0;url=form_login.php");
}
if(!isset($_COOKIE["cart"])||$_COOKIE["cart"]==null){
die();
}
include("common/dbconnection.php");
$cart=explode(" ",$_COOKIE["cart"]);
foreach($cart as $elem){
$product=explode(",",$elem);
try {
$stmt = $conn->prepare("INSERT INTO purchases(iduser, product,quantity) VALUES (:user,:product,:quantity)");
$stmt->bindParam(":user",$_SESSION["uid"]);
$stmt->bindParam(":product",$product[0]);
$stmt->bindParam(":quantity",$product[1]);
$stmt->execute();
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
}
}
?>
<script>
deletecart()
window.location.replace("main.php")
</script>
</body>
</html>