RedChu

Untitled

Apr 18th, 2011
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.24 KB | None | 0 0
  1. <?php
  2.  
  3. // Added these variables for security reasons and because it makes it a bit simpler in my opinion - RC
  4.  
  5. $name = mysql_real_escape_string($_GET['name']);
  6. $score = mysql_real_escape_string($_GET['score']);
  7. $wave = mysql_real_escape_string($_GET['wave']);
  8.  
  9. //first the query try to get a riw where the name of the player is = to the name in the url
  10.  
  11. $query = "SELECT name FROM highscore WHERE name='$name'";
  12.  
  13. $res = mysql_query($query) or die("Couldn't execute $query: ".mysql_error());
  14.  
  15.  
  16.  
  17. //if the query returns 0 rows the player doesn't exist, if it returns 1 the player already exists
  18.  
  19. if (mysql_num_rows($res)==0)
  20.  
  21. {
  22.  
  23. //the query makes a new row with the player name and the score
  24.  
  25. // now i want to edit the following to also insert the wave $_GET["wave"]; and on the next function also set to $_GET["wave"];
  26.  
  27. $query = "INSERT INTO highscore (name, score, wave) VALUES ('$name','$score','$wave')";
  28.  
  29. mysql_query($query) or die("Couldn't execute $query: ".mysql_error());
  30.  
  31. }
  32.  
  33. else
  34.  
  35. {
  36.  
  37. //the query looks for the row with name=name in the url and updates his score
  38.  
  39. $query = "UPDATE highscore SET score='$score', wave='$wave' WHERE name='$name'";
  40.  
  41. mysql_query($query) or die("Couldn't execute $query: ".mysql_error());
  42.  
  43. }
  44.  
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment