· 5 years ago · Feb 02, 2020, 03:06 AM
1<?php
2 // Connect to database
3 $db = new PDO('mysql:host=localhost;dbname=[REDACTED]', '[REDACTED]');
4
5 // Check secret key, if correct, then get names and scores
6 $has_found = 0;
7 $secret_key = "[REDACTED]";
8 if($secret_key == $_POST['secret_key'])
9 {
10 // Get data from the table
11 $sql = "SELECT name, money, xp, bitcoin, tokens FROM Cache";
12 $stmt = $db->prepare($sql);
13 $stmt->bindParam('name', $name, PDO::PARAM_STR);
14 $stmt->execute();
15
16
17 while($row = $stmt->fetch(PDO::FETCH_ASSOC))
18 {
19
20
21 if($row['name'] == $_POST['name'])
22 {
23 $result = $row;
24 $has_found = 1;
25 echo json_encode($result);
26 }
27 }
28 }
29?>