· 5 years ago · Feb 01, 2020, 11:06 PM
1<?php
2 // Connect to database
3 $db = new PDO('mysql:host=localhost;dbname=my_sotpyrc', 'sotpyrc');
4
5 // Check secret key, if correct, then get names and scores
6 $has_found = 0;
7 $secret_key = "1234";
8 if($secret_key == $_POST['secret_key'])
9 {
10 // Get data from the table
11 $sql = "SELECT VALUES (:id, :name, :money, :xp, :bitcoin, :tokens) FROM Cache";
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;
21echo {"name":"$row['name']","money":"$row['money']","xp":"$row['xp']","bitcoin":"$row['bitcoin']","tokens":"$row['tokens']"};
22 }
23
24
25
26 }
27 }
28?>