-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyt.php
81 lines (77 loc) · 2.05 KB
/
pyt.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
<html>
<head>
<center> <h1>Payment Module<h1>
<h3>Debit Card</h3>
</center>
</head>
<body>
<center><h1></h1><br><br>
<form action="pyt.php"method="post" class="fo">
<button type="Submit" name="view" >View Account Details</button>
<button type="Submit" name="ppy"> Proceed to Payment</button>
<a href="logoutbnk.php"><button type="button" name="d">Logout</button></a>
<?php
session_start();
require_once('dbconfig/config.php');
if(isset($_POST['view'])){
$con=connect();
$cn=$_SESSION['cn'];
$c="create view from train,bnk";
$sql="SELECT * from bnk where cn='$cn' ";
$result = $con->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<h3><br><b>Card Number:</b> " . $row["cn"]."<br></h3>";
echo "<h3><b>Name on Card:</b> " . $row["nc"]."<br></h3>";
echo "<h3>Account Balance: Rs. " . $row["rs"]."<br></h3>";
}}
else{
echo "error in database";
}
}
?>
<?php
require_once('dbconfig/config.php');
if(isset($_POST['ppy'])){
$con=connect();
$cn=$_SESSION['cn'];
$sql="SELECT * from bnk where cn='$cn' ";
$result = $con->query($sql);
if ($result->num_rows ==1) {
$ro= $result->fetch_assoc();
if($ro!== null){
$c=$ro['rs'];
$d=$ro['em'];
$sq="SELECT * from train where em='$d'" ;
$r = $con->query($sq);
$s="Update train set py='1' where em='$d'";
$re = $con->query($s);
if ($r->num_rows > 0) {
while($row = $r->fetch_assoc()) {
echo "<h3><br><b>Amount Paid: Rs.</b> " . $row["fare"]."<br></h3>";
$b=$row["fare"];
}}
else {
echo "no results";
}
//echo $b."<br>";
//echo $c."<br>";
$c=$c-$b;
//echo $c."<br>";
$s="Update bnk set rs='$c' where em='$d'";
$result = $con->query($s);
if ($result) {
echo "<br><br> Payment is Paid Successfully<br>";
}
else{
echo '<script type="text/javascript">alert("Payment failed")</script>';
}
echo "<h3><br><b>Amount Balance: Rs.</b> " .$c."<br></h3>";
}}
else {
echo "no results";
}}
?>
</form></center>
</body>
</html>