-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccount.php
79 lines (69 loc) · 1.88 KB
/
account.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
<?php
/*
* File: account.php
* File Created: Monday, 30th September 2019
* Author: Syed Faraz Abrar
* -----
* Last Modified: Monday, 14th October 2019
* Modified By: Syed Faraz Abrar
* -----
* Purpose: This is the user's account page, only
* to be visible to the user that is
* currently logged in. It displays the
* user's account ID and email, and lets
* the user add money to their account.
*/
require_once("db.php");
require_once("includes/check_session.php");
include("includes/handle_balance.php");
?>
<!DOCTYPE html>
<html>
<head>
<?php
include_once("includes/includes.php");
// Use a GET request to get the correct account information
if (!isset($_GET["id"]))
{
$id = $_SESSION["id"];
header("Location: /account.php?id=$id");
}
?>
</head>
<body>
<?php
include_once('includes/header.php');
?>
<div class="container">
<!-- User data is shown in a table -->
<table class="table">
<thead>
<th>Account ID</th>
<th>Email</th>
<th>Balance</th>
</thead>
<tbody>
<?php
// Use the GET variable "id" to get the correct user information
$id = $_GET["id"];
$sql = "SELECT id, username, email, balance FROM Users where id=$id;";
$result = mysqli_query($db, $sql);
echo mysqli_error($db);
$row = mysqli_fetch_array($result);
echo '<h1>Welcome back '.$row[1].'!</h1>';
echo "<tr>";
echo "<td>$row[0]</td>"; // user id
echo "<td>$row[2]</td>"; // user email
echo "<td>\$$row[3]</td>" // user's balance
?>
</tbody>
</table>
</div>
<div class="d-flex justify-content-center">
<form class="form-inline" action="" method="POST">
<input class="form-control mr-sm-2" type="number" placeholder="Balance" aria-label="Balance" name="balance">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit" name="submit" value="submit">Add Balance</button>
</form>
</div>
</body>
</html>