-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.php
98 lines (92 loc) · 3.13 KB
/
login.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
<!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>User Details</title>
<style>
html{
background-color: rgb(70, 194, 152);
text-align: center;
}
h1{
font-size: 50px;
color:black;
text-transform: capitalize;
}
p{
font-size: 30px;
color: whitesmoke;
}
.form{
padding: 5px;
text-align: left;
border: 3px solid black;
}
</style>
</head>
<body>
<?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());
}
$name="";
if(isset($_POST['save'])){
$name = $_POST['save'];
}
$sql_query = "select * from users where username = '$name'";
$result = mysqli_query($conn,$sql_query);
$element =mysqli_fetch_assoc($result);
?>
<h1>selected user Details</h1>
<p><b>Id : </b><?php echo $element['id'] ?></p>
<p><b>Name : </b><?php echo $element['username'] ?></p>
<p><b>Balance : </b><?php echo $element['balance'] ?> Rs</p>
<hr>
<h1>Transfer Money</h1>
<div class="form" id="form">
<script>
function check_amount(){
if (parseInt(document.getElementById('amt').value) > parseInt("<?php echo $element['balance'];?>")){
alert('You don\'t have enough amount');
return false;
}
if (document.getElementById('amt').value =='0' ){
alert('Please enter a valid amount');
return false;
}
}
</script>
<form action="transfer.php" method ="post" onsubmit="return check_amount()">
<br>
<input type="text" name="u1" id='u1' value="<?php echo $element['username'] ?>" style="display: none;">
<label style="color: whitesmoke; margin: 20px;">Transfer to :</label>
<select name="u2" id="u2" required>
<option value="">--Select a user--</option>
<?php
$sql_query2 = "select * from users where username != '$name'";
$result2 = mysqli_query($conn,$sql_query2);
$noRow= mysqli_num_rows($result2);
for ($i=0; $i < $noRow; $i++) {
$element2 =mysqli_fetch_assoc($result2);
echo "<option value=".$element2['username'].">".$element2['username']."</option>";
}
?>
</select>
<br>
<br>
<label style="color: whitesmoke; padding: 20px;">Amount : </label>
<input type="number" name="amount" id="amt" required>
<br>
<label style="position: relative; margin:10px; top:50px;"><input type="submit" value="Transfer" name="save"></label>
</form>
</div>
</body>
</html>