Guest User

Untitled

a guest
Jul 24th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. class MyScoreDB{
  2.  
  3. public function connectDB(){
  4.  
  5. $host = 'localhost'; // Your MySQL Host
  6. $username = 'xxxx'; // Your MySQL Username
  7. $password = 'xxx'; // Your MySQL Pass
  8. $dbname = 'xxxx'; // Your MySQL DB
  9.  
  10. mysql_connect($host, $username, $password) or die(mysql_error());
  11.  
  12. mysql_select_db($dbname) or die(mysql_error());
  13.  
  14. return 0;
  15.  
  16. }
  17.  
  18. public function insertScore($name,$score){
  19.  
  20. $name = addslashes($name);
  21. mysql_query("INSERT INTO scores(name,score) VALUES ('".$name."','".$score."')") or die(mysql_error());
  22.  
  23. return 0;
  24.  
  25. }
  26.  
  27. }
  28.  
  29. $OS = new MyScoreDB();
  30. $OS->connectDB();
  31.  
  32. if($_GET['sc'] == ""){
  33. $score = '0%';
  34. $name = 'Your';
  35. }else{
  36. $score = $_GET['sc'];
  37. $name = $UserName;
  38.  
  39. $OS->insertScore($name,$score);
  40. };
Add Comment
Please, Sign In to add comment