-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayment.php
145 lines (124 loc) · 4.86 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php include('partials-front/navbar.php'); ?>
<?php
if(isset($_SESSION['order']))
{
echo $_SESSION['order'];
unset($_SESSION['order']);
}
if(isset($_SESSION['pay']))
{
echo $_SESSION['pay'];
unset($_SESSION['pay']);
}
?>
<div class="categories text-center">
<div class="container">
<?php
if(isset($_GET['order_id']))
{
// get the order details
$order_id = $_GET['order_id'];
$sql = "SELECT * FROM tbl_order WHERE id = $order_id";
// execute the query
$res = mysqli_query($conn, $sql);
// check if the query is executed or not
if ($res == TRUE)
{
// query is executed
// fetch order details
while ($row= mysqli_fetch_assoc($res))
{
$title = $row['food'];
$qty = $row['qty'];
$total = $row['total'];
$customer_name = $row['customer_name'];
$customer_email = $row['customer_email'];
?>
<h2 class="text center">Hello, <?php echo $customer_name; ?>. Pay Rs. <?php echo $total; ?>, to confirm your order <?php echo $qty." quantity ". $title; ?></h2>
<?php
}
}
else
{
echo "no order";
}
}
?>
<br><br>
<h3 class="text-center">Credit Card</h3>
<form action="" method="POST" class="order">
<table >
<tr>
<td>
Name on the card:
</td>
<td>
<input type="text" name="card_name" placeholder="Enter the name on your card" style="border-radius:0.4rem; padding:0.2rem; height:4vh; " required>
</td>
</tr>
<tr>
<td>
Credit Card Number:
</td>
<td>
<input type="tel" maxlength="14" name="credit-card-number" placeholder="XXXX XXX XXX XXXX" style="border-radius:0.4rem; padding:0.2rem; height:4vh;" required>
</td>
</tr>
<tr>
<td>
CVV Number:
</td>
<td>
<input type="password" maxlength="3" name="CVV-number" placeholder="XXX" style="border-radius:0.4rem; padding:0.2rem; height:4vh; " required>
</td>
</tr>
<tr>
<td>
Expiry Date:
</td>
<td>
<input type="date" name="exp-date" style="border-radius:0.4rem; padding:0.2rem; height:4vh;" required>
</td>
</tr>
<tr>
<td colspan='2' class="text-center">
<input type="hidden" name = "customer_email" value="<?php echo $customer_email?>">
<button type = 'submit' name = "submit" class='btn btn-primary'>Pay Now</button>
</td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit']))
{
// get the details
$card_name = $_POST['card_name'];
$card_number = $_POST['credit-card-number'];
$cvv_number = $_POST['CVV-number'];
$expiry_date = $_POST['exp-date'];
// sql query for the data
$sql2 = "INSERT INTO tbl_payment SET
card_name = '$card_name',
card_number = $card_number,
cvv_number = $cvv_number,
expiry_date = '$expiry_date'
";
// execute the query
$res2 = mysqli_query($conn, $sql2);
// check whether the query is executed or not
if ($res2 == true)
{
$_SESSION['pay'] = '<div class="success">You have paid!</div>';
header('location:'.SETURL.'delivered.php');
}
else
{
// display query message
$_SESSION['pay'] = '<div class="error">Invalid credentials</div>';
header('location:'.SETURL.'delivered.php');
}
}
?>
</div>
</div>
<?php include('partials-front/footer.php') ;?>