-
Notifications
You must be signed in to change notification settings - Fork 3
/
redeem.php
70 lines (57 loc) · 2.24 KB
/
redeem.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
<?php
include "connection.php";
if(isset($_POST['id']))
{
$getpoints = $conn->prepare("SELECT points FROM `users` WHERE id = '".$_POST["id"]."' " );
$getpoints->execute();
$row = $getpoints->fetch(PDO::FETCH_ASSOC);
$x =$row["points"];
if($_POST['redeem'] == "8EB-CBRP-DCVM-ELTD-FCCZ-91ZZ"){
$y=500;
$z=$x+$y;
$sql = "UPDATE `users` SET `points` = '".$z."'
WHERE id = '".$_POST["id"]."' ";
$statement = $conn->prepare($sql);
//$statement->bindValue(':points', $_POST['points']);
$updated = $statement->execute();
if($updated){
$sth = $conn->prepare("SELECT * FROM users WHERE id = '".$_POST["id"]."' " );
$sth->execute();
$result2 = $sth->fetch(PDO::FETCH_ASSOC);
echo json_encode($result2);
}
}elseif ($_POST['redeem'] == "BV4-6RJ0-PDG3-0T8X-TTHU-39P1") {
$y=1000;
$z=$x+$y;
$sql = "UPDATE `users` SET `points` = '".$z."'
WHERE id = '".$_POST["id"]."' ";
$statement = $conn->prepare($sql);
//$statement->bindValue(':points', $_POST['points']);
$updated = $statement->execute();
if($updated){
$sth = $conn->prepare("SELECT * FROM users WHERE id = '".$_POST["id"]."' " );
$sth->execute();
$result2 = $sth->fetch(PDO::FETCH_ASSOC);
echo json_encode($result2);
}
}
/*if(isset($_POST['points'])) {
$sql = "UPDATE `users` SET `points` = :points
WHERE id = '".$_POST["id"]."' ";
$statement = $conn->prepare($sql);
$statement->bindValue(':points', $_POST['points']);
$updated = $statement->execute();
if($updated){
$sth = $conn->prepare("SELECT * FROM users WHERE id = '".$_POST["id"]."' " );
$sth->execute();
$result2 = $sth->fetch(PDO::FETCH_ASSOC);
echo json_encode($result2);
}
}else {
$sth = $conn->prepare("SELECT * FROM users WHERE id = '".$_POST["id"]."' " );
$sth->execute();
$result2 = $sth->fetch(PDO::FETCH_ASSOC);
echo json_encode($result2);
}*/
}
?>