-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpayment.php
53 lines (51 loc) · 1.23 KB
/
payment.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
<?php
require_once 'init.php';
if(
isset($_SESSION['name']) &&
isset($_GET['total_cost'])
){
$username = $_SESSION['name'];
$balance = (int) $_SESSION['money'];
$total_cost = (int) $_GET['total_cost'];
$new_balance = $balance -= $total_cost;
if($new_balance < 0){
$error = "<h1>{$username}, <br/>Please top up your wallet!</h1>";
}else{
$_SESSION['money'] = $new_balance;
$message = <<<HTML
<h1>Thank You!</h1>
<h3>Your wallet has been successfully charged for {$total_cost} Baht.</h3>
<p>Username: {$username}</p>
<p>Your money: {$new_balance} Baht</p>
HTML;
}
}else{
$error = '<h1>unauthorized access.</h1>';
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="author" content="Pichaya Morimoto">
<title> Pwnladin's Cat Shop </title>
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css">
</head>
<body>
<div class="jumbotron">
<?php
if( ! empty($error) ):
echo $error;
else:
echo $message;
endif;
?>
<p><a onclick="goBack()" class="btn btn-primary btn-lg" role="button">Go Back</a></p>
</div>
<script>
function goBack() {
window.history.back()
}
</script>
</body>
</html>