· 5 years ago · Feb 02, 2020, 02:22 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 all data from the table, ordering from best to worst
11 $sql = "SELECT FROM Cache VALUES (:id, :name, :money, :xp, :bitcoin, :tokens)";
12 $stmt = $db->prepare($sql);
13 $stmt->execute();
14
15 $result = [];
16 while($row = $stmt->fetch(PDO::FETCH_ASSOC))
17 {
18
19 if($row['name'] == $_POST['name'])
20 {
21 $has_found = 1;
22 $result[] = $row;
23 }
24 }
25
26 $json = json_encode($result);
27 }
28?>