-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuy.php
76 lines (64 loc) · 2.25 KB
/
buy.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
<?php require("auth.php"); ?>
<?php
$id = $_SESSION['id'];
$dbh = new PDO('mysql:host=localhost;dbname=skillx', 'root');
$stmt = $dbh->prepare("SELECT points FROM users WHERE id=:id");
$stmt->execute(array(':id' => $id));
$user = $stmt->fetch();
if (empty($_GET['p'])):
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="theme-color" content="#5E5DA9">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="/css/common.css">
<link rel="stylesheet" type="text/css" href="/css/buy.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<?php require("topbar.php"); ?>
<div class="main">
<h2>Buy Points</h2>
<a href="?p=500" class="offer">
<div class="offer-dollar">
<div class="offer-dollar-icon"><i class="material-icons">attach_money</i></div>
<div class="offer-dollar-number">25</div>
</div><div class="offer-point">
<div class="offer-point-number">500</div>
<div class="offer-point-icon"><i class="material-icons">star</i></div>
</div>
</a>
<a href="?p=1000" class="offer">
<div class="offer-dollar">
<div class="offer-dollar-icon"><i class="material-icons">attach_money</i></div>
<div class="offer-dollar-number">40</div>
</div><div class="offer-point">
<div class="offer-point-number">1000</div>
<div class="offer-point-icon"><i class="material-icons">star</i></div>
</div>
</a>
<a href="?p=4000" class="offer">
<div class="offer-dollar">
<div class="offer-dollar-icon"><i class="material-icons">attach_money</i></div>
<div class="offer-dollar-number">99</div>
</div><div class="offer-point">
<div class="offer-point-number">4000</div>
<div class="offer-point-icon"><i class="material-icons">star</i></div>
</div>
</a>
</div>
</body>
</html>
<?php
else:
$points_new = $user['points'] + $_GET['p'];
$dbh = new PDO('mysql:host=localhost;dbname=skillx', 'root');
$stmt = $dbh->prepare("UPDATE users SET points = :points WHERE id = :id");
$stmt->execute(array(':points' => $points_new, ':id' => $_SESSION['id']));
header("Location: /user.php");
endif;
?>