Guest User

Untitled

a guest
Mar 9th, 2017
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. $servername = "localhost";
  5. $username = "Molgan1337";
  6. $password = "rekt";
  7. $dbname = "Molgan1337";
  8. $tablename = "Tabell";
  9.  
  10. $name = $_POST['name'];
  11. $score = $_POST['score'];
  12. $recivedHash = $_POST['hash'];
  13. $secretKey = "Turtle";
  14.  
  15. //create connection :)
  16. $db = new mysqli($servername, $username, $password, $dbname);
  17.  
  18.  
  19.  
  20. //check connection
  21.  
  22. if($db->connect_error)
  23. {
  24.  
  25. die("cunt" . $db->connect_error);
  26. }
  27. else
  28. echo "Connection succesful! \n";
  29.  
  30.  
  31. $hash = md5($name . $score . $secretKey); //the correct hash
  32.  
  33. //Check validation (is the recived hash correct)
  34. if($hash == $recivedHash)
  35.  
  36. {
  37.  
  38. $sql = "INSERT INTO " . $tablename . " (Name,Score) VALUES ('" . $name . "', '" . $score . "')";
  39.  
  40.  
  41.  
  42. //query the database
  43. if($db->query($sql) === true)
  44. {
  45. echo "kys fag \n";
  46. echo $name . " with the score" . $score;
  47. }
  48. else echo "Error" . $sql . "\n" . $db->error;
  49. }
  50. $db->close();
  51.  
  52.  
  53. ?>
Add Comment
Please, Sign In to add comment