test
1 week ago in PHP
<?php
$MySQLdb = new PDO("mysql:host=127.0.0.1;dbname=live", "root", "");
$MySQLdb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
session_start();
$user = $_SESSION["username"];
if(!isset($_SESSION["username"])){
header("location:index.php");
}else{
header('HTTP/1.1 200 OK', true, 200);
}
$cursor = $MySQLdb->prepare("SELECT * FROM users WHERE username=:username");
$cursor->execute( array(":username"=>$_SESSION["username"]) );
if($row = $cursor->fetch()){
$money = $row["money"];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>or-bank</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./assets/css/bootstrap.min.css">
<link rel="stylesheet" href="./assets/css/custom.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="./assets/js/bootstrap.min.js"></script>
</head>
<style>
#name{
wi
}
</style>

<body>
<link rel="icon" href="fbi.png" type="image/gif" sizes="16x16">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">FORUM</a>
</div>
<ul class="nav navbar-nav" style="float: right">
<li><a href="profile.php" id="logout">Profile</a></li>
<li><a href="MoneyT.php" id="logout">Money Transfer</a></li>
<li><a href="logout.php" id="logout">Logout</a></li>
</ul>
</div>
</nav>

<div class="container">
<div class="row" id="page" hidden>
<div class="col-md-3">
<div class="panel panel-default">
<div class="panel-heading"><h4>Account Info</h4></div>
<div class="panel-body">
<ul class="list-group">
<li class="list-group-item">
<p>
<kbd>username:</kbd>
<span style="float:right;">
<?php echo $user; ?>
</span>
</p>
</li>
<li class="list-group-item">
<p>
<kbd>ip address</kbd>
<span style="float:right;">
<?php echo $_SERVER["REMOTE_ADDR"];?>
</span>
</p>
</li>
</ul>
</div>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-default">
<div class="panel-heading">
<h4>money Transfer system test<><h4>
</div>
<kbd>your balance is:<?php echo $money?>$</kbd>
<style>
input[type=text], select {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}

input[type=submit] {
width: 100%;
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}

input[type=submit]:hover {
background-color: #45a049;
}

div {
border-radius: 5px;
background-color: #f2f2f2;
padding: 0px;
}
</style>
<br>
<div>
<br>
<label for="fname">how much?:</label>
<input type="text" id="inp" name="firstname" placeholder="number">

<label for="country">To:</label>
<select id="country" name="country">
<option value="australia">user1</option>
<option value="canada">user2</option>
<option value="usa">user3</option>
</select>

<button id="btn">click me!</button>

</div>
<p>
<input type="text" id="change_Addres_inp10"><button id="change_name_btn40" type="button" class="btn btn-primary">Change money</button>
</div>
</p>

<script>
//$("#btn").click(function(){

//$.post("api.php",{"action":"money","money":$("#inp").val()},function(data))

//});
$.post("api.php",{"action":"get_all"},function(data){
console.log(data[0].username);
});
$("#change_name_btn40").click(function(){
$.post("api.php",{"action":"change_money","new_money":$("#change_Addres_inp10").val()},function(data){
if(data.success == "true"){
//$("#h2").text(data.data)

$("#MSG").html('<div class="alert alert-success"><strong>success:'+data.data+'</strong></div>').fadeIn().delay(2000).fadeOut();
setTimeout(function(){ location.reload();; }, 300);
}else{
$("#MSG").html('<div class="alert alert-danger"><strong>Error:'+data.data+'</strong></div>').fadeIn().delay(1000).fadeOut();
}
})
});
</script>



<script>
$("#page").slideDown("slow");

</script>

</body>
</html>
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