-
Notifications
You must be signed in to change notification settings - Fork 6
/
payment.php
57 lines (51 loc) · 1.48 KB
/
payment.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
<?php
include 'lock.php';
$money = $_SESSION['net_amount'];
$id = $_SESSION['cust_id'];
$connection = mysqli_connect("localhost","root","","studyportal");
if($connection->connect_error){
echo "Connection Error:" .$connection->connect_error."<br/> <a href=books.php>Go Back </a> and retry!";
}
?>
<html>
<head>
<title>Wait...</title>
<style>
</style>
</head>
<body>
<form method="post" action="">
<h1>Payment Confirmation</h1>
<br/>
Amount to be paid: <?php echo $money;?><br/>
<input type="hidden" name="cc_debit" value=<?php echo ($money);?>/>
<!-- Below code line will secure payment -->
<!--<input type="hidden" name="cc_debit" value=<?php echo md5($money);?>/>-->
<input type="submit" name="complete" value="PAY NOW!"/>
</form>
<h2>OR</h2><br/>
<a href="cancel.php">Cancel Order</a>
</body>
</html>
<?php
if(isset($_POST['complete'])){
$actual_amt = $_POST['cc_debit'];
$get = "SELECT * from orders order by order_date desc limit 1";
$result = $connection->query($get);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$id = $row['order_id'];
} }
else {
echo "0 results";
}
$sql = "INSERT into payment(order_id,total_amount,customer) values ('$id','$actual_amt','$login_session')";
if($connection->query($sql)=== TRUE){
header("Location:thank.php");
}
else{
echo "ERROR!<a href=books.php>Click here</a> to go back and retry!";
}
}
?>