| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- $HOST = 'nordh.xyz';
- $USERNAME = 'narKampen';
- $PASSWORD = '9Bq.6[AcTc2ADwN-';
- $DATABASE = 'narKampen';
- $PORT = '3306';
- $secretKey = 'TheNarKampenSecretKey';
- try {
- $dbh = new PDO(
- 'mysql:host=' . $HOST . ';dbname=' . $DATABASE,
- $USERNAME,
- $PASSWORD
- );
- } catch (PDOException $e) {
- echo '<h1>An error har occured. </h1><pre>', $e->getMessage(), '</pre>';
- }
- // Example of setting data
- $realHash = md5($_GET['name'] . $_GET['score'] . $secretKey);
- if ($realHash == $hash) {
- $sth = $dbh->prepare('INSERT INTO scores VALUES (null, :name, :score)');
- try {
- $sth->execute($_GET);
- } catch (Exception $e) {
- echo '<h1>An error has ocurred.</h1><pre>', $e->getMessage(), '</pre>';
- }
- }
- // Example of getting data
- $sth = $dbh->query('SELECT * FROM scores ORDER BY score DESC LIMIT 5');
- $sth->setFetchMode(PDO::FETCH_ASSOC);
- $result = $sth->fetchAll();
- if (count($result) > 0) {
- foreach ($result as $r) {
- echo $r['name'], "\t", $r['score'], "\n";
- }
- }
|