· 7 years ago · Oct 24, 2018, 09:30 PM
1<?php
2 // Connect to database
3 $db = new PDO('mysql:host=localhost;dbname=my_jeffdev', 'jeffdev');
4
5 // Check secret key, if correct, then insert name and score
6 $secretKey = "MySecretKey";
7 if($secretKey == $_POST['MySecretKey'])
8 {
9 // Prepare statement
10 $sql = "INSERT INTO Micro VALUES (NULL, :name, :score)"; // Change OnlineHighscores to your game name
11 $stmt = $db->prepare($sql);
12 $stmt->bindParam(':name', $name, PDO::PARAM_STR);
13 $stmt->bindParam(':score', $score, PDO::PARAM_INT);
14
15 // Get name, score and hash from URL string
16 $name = $_POST['name'];
17 $score = $_POST['score'];
18
19 // Execute statement
20 $stmt->execute();
21 echo '1';
22 }
23 else
24 {
25 echo '0';
26 }
27?>