-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckout.php
96 lines (84 loc) · 3.25 KB
/
checkout.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
<?php
/**
* Created by PhpStorm.
* User: ashir
* Date: 3/28/16
* Time: 11:29 AM
*/
require 'config/conn.php';
require 'include/header.php';
require 'include/auth.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
try {
/*$conn->beginTransaction();*/
$SQL= $conn->prepare("INSERT INTO ProductOrder (OrderDate, Total ,Username) VALUES(?,?,?) ");
$OrderDate = date("Y-m-d H:i:s");
$SQL->bindValue("1",$OrderDate);
$SQL->bindValue("2",$_SESSION["total"]);
$SQL->bindValue("3",$_SESSION["userid"]);
$SQL->execute();
$id = $conn->lastInsertId();
echo $id . "<br/>";
foreach ($_SESSION["cart"] as $key=>$value) {
echo $value . "<br/>";
echo $key . "<br/>";
$SQL = $conn->prepare("INSERT INTO OrderLines (ProductId,OrderId,Qty) VALUES(?,?,?)");
$SQL->bindValue("1",$key);
$SQL->bindValue("2",$id);
$SQL->bindValue("3",$value);
$SQL->execute();
}
} catch (PDOException $e) {
//$conn->rollBack();
echo "Error: " . $e->getMessage() . "<br />\n";
}
unset($_SESSION['cart']);
unset($_SESSION["total"]);
}
if (!isset($_SESSION["total"])) {
header('location:index.php');
exit();
}
?>
<div class="col-md-offset-3 col-md-6">
<div class="well bs-component">
<form class="form-horizontal" method="post">
<fieldset>
<legend>Payment Info</legend>
<div class="form-group">
<label for="inputEmail" class="col-lg-2 control-label">Name</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputEmail" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="col-lg-2 control-label">Address</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="address" id="inputPassword" placeholder="Address">
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="col-lg-2 control-label">Credit Card</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputPassword" placeholder="Credit Card">
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="col-lg-2 control-label">Total</label>
<div class="col-lg-10">
<label>$<?=$_SESSION["total"]?></label>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<button type="reset" class="btn btn-default">Cancel</button>
<button type="submit" class="btn btn-primary">Confirm Payment</button>
</div>
</div>
</fieldset>
</form>
<div id="source-button" class="btn btn-primary btn-xs" style="display: none;">< ></div></div>
</div>
<?php
require 'include/footer.php';
?>