forked from ayshagazi/E-Learn-Management-System
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckout.php
More file actions
186 lines (134 loc) · 4.16 KB
/
checkout.php
File metadata and controls
186 lines (134 loc) · 4.16 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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
include('./dbConnection.php');
if(!isset($_SESSION))
{
session_start();
}
if(!isset($_SESSION['stuLogEmail'])){
echo "<script>location.href='loginorsignup.php'</script>";
}
else{
header("Pragma: no-cache");
header("Cache-Control: no-cache");
header("Expires: 0");
$stuEmail= $_SESSION['stuLogEmail'];
if(isset($_POST['purchase'])){
$order_id = $_POST['Order_ID'];
$stuEmail= $_SESSION['stuLogEmail'];
$course_id= $_SESSION['course_id'];
$amount=$_POST['TXN_AMOUNT'];
$yee='';
$flag='';
$sql2="SELECT course_id FROM courseorder WHERE stu_email ='$stuEmail'";
$runquery= mysqli_query($conn,$sql2) or die(mysqli_error($conn));
while($result2=mysqli_fetch_array($runquery)){
$yee=$result2['course_id'];
if($yee==$course_id){
$flag="gggg";
}
}
if($flag!=''){
echo"
<script>
alert('You have already purchased this course ');
window.location.href='./Student/myCourse.php';
</script>
";
}else{
$sql ="INSERT INTO courseorder(order_id, stu_email, course_id,amount) VALUES ('$order_id','$stuEmail', '$course_id','$amount')";
if($conn->query($sql)==TRUE){
//echo json_encode("OK");
//echo "Congratulations!!!! Purshased Successfully...";
echo"
<script>
alert('Congratulations!!!! Purshased Successfully...');
window.location.href='./Student/myCourse.php';
</script>
";
//echo"<script>setTimeout(()=>{
// window.location.href='./Student/myCourse.php';
// },1500);</script>";
}else{
echo"
<script>
alert(' Already Purshased');
</script>
";
echo"<script>setTimeout(()=>{
window.location.href='./courses.php';
},1500);</script>";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="GENERATOR" content="Eversoft First Page">
<meta name= "viewport" content="width=device-width,initial-scale=1.0">
<title>CheckOut</title>
<!-- Bootstrap CSS-->
<link rel ="stylesheet" href="css/bootstrap.min.css">
<!--Google Font-->
<link href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@700&display=swap" rel="stylesheet">
<!--Custom CSS-->
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container mt-5">
<div class="row">
<div class="col-sm-6 offset-sm-3 jumbotron">
<h3 class="mb-5">Welcome to eLearn Payment</h3>
<form method="post">
<div class="form-group row">
<label for="Order_ID" class="col-sm-4 col-form-label">Order ID</label>
<div class="col-sm-8">
<input id="Order_ID" class="form-control"
tabindex="1" size="20" name="Order_ID"autoComplete="off"
value="<?php echo "ORDS".rand(10000,99999999)?>" readonly>
</div>
</div>
<div class="form-group row">
<label for="CUST_ID" class="col-sm-4 col-form-label">Student Email</label>
<div class="col-sm-8">
<input id="CUST_ID" class="form-control"
tabindex="2" size="12" maxLength="12" name="CUST_ID"autoComplete="off"
value="<?php if(isset($stuEmail)){echo $stuEmail;} ?>" readonly>
</div>
</div>
<div class="form-group row">
<label for="TXN_AMOUNT" class="col-sm-4 col-form-label">Amount</label>
<div class="col-sm-8">
<input title="TXN_AMOUNT" class="form-control"
tabindex="10" type="text" name="TXN_AMOUNT"
value="<?php if(isset($_POST['id'])){echo $_POST['id'];} ?>" readonly>
</div>
</div>
<div class="form-group row">
<div class="col-sm-8">
<input id="INDUSTRY_TYPE_ID" class="form-control"
tabindex="4" type="hidden" maxLength="12" size="12" name="INDUSTRY_TYPE_ID"
autoComplete="off" value="Retail" readonly>
</div>
</div>
<div class="form-group row">
<div class="col-sm-8">
<input id="CHANNEL_ID" class="form-control"
tabindex="4" type="hidden" maxLength="12" size="12" name="CHANNEL_ID"
autoComplete="off" value="WEB" readonly>
</div>
</div>
<div class="text-center">
<input value="Checkout" name="purchase" type="submit" class="btn btn-primary" onclick="">
<a href="./courses.php" class="btn btn-secondary">Cancel</a>
</div>
</form>
<small class="form-text text-muted">Note: Purchase The Course by Clicking Checkout Button </small>
</div>
</div>
</div>
</body>
</html>
<?php }
?>