· 5 years ago · Feb 01, 2020, 10:32 PM
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 while($row = $stmt->fetch(PDO::FETCH_ASSOC))
16 {
17
18 if($row['name'] == $_POST['name'])
19 {
20 $has_found = 1;
21 echo {"name":"$row['name']","money":"$row['money']","xp":"$row['xp']","bitcoin":"$row['bitcoin']","tokens":"$row['tokens']"};
22 }
23 }
24 }
25?>