-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtransfer.php
64 lines (60 loc) · 1.84 KB
/
transfer.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Recipt</title>
<style>
html{
background-color: rgb(70, 194, 152);
padding: 10%;
font-size: 300%;
color: white;
}
</style>
</head>
<body>
<p>Transaction Status : </p>
<?php
$servername="localhost";
$username="root";
$password="";
$database_name="banking";
$conn=mysqli_connect($servername,$username,$password,$database_name);
//now check for connection
if(!$conn){
die("connection failed:".mysqli_connect_error());
}
if(isset($_POST['save'])){
$u1 = $_POST['u1'];
$tamount = $_POST['amount'];
$u2 = $_POST['u2'];
$sql_query = "select balance from users where username = '$u1'";
$result = mysqli_query($conn,$sql_query);
$element =mysqli_fetch_assoc($result);
$u1b = $element['balance'];
$u1b -=$tamount;
$sql_query = "select balance from users where username = '$u2'";
$result = mysqli_query($conn,$sql_query);
$element =mysqli_fetch_assoc($result);
$u2b = $element['balance'];
$u2b +=$tamount;
$sql_query = "UPDATE users SET balance = '$u1b' WHERE username = '$u1'";
mysqli_query($conn,$sql_query);
$sql_query = "UPDATE users SET balance = '$u2b' WHERE username = '$u2'";
mysqli_query($conn,$sql_query);
$sql_query = "INSERT INTO transaction (u1,u2,amount) VALUES ('$u1', '$u2', '$tamount')";
if(mysqli_query($conn,$sql_query)){
echo "Transaction successful !";
}else{
echo "Transaction Unsuccessful !";
}
mysqli_close($conn);
}
?>
<br>
<br>
<a href="index.html" style="color:rgb(70, 194, 152) ; background-color: white;padding: 1%; text-decoration: solid; ">Go back</a>
</body>
</html>