Advertisement
Guest User

Untitled

a guest
Mar 28th, 2016
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. <?php
  2. // Connection details
  3. $servername = "YOUR_SERVER_NAME E.G. WWW.BRAZZERS.COM";
  4. $user = "YOUR_DATABASE_USERNAME";
  5. $password = "YOUR_DATABASE_PASSWORD";
  6. $dbname = "THE_NAME_OF_THE_DATABASE";
  7.  
  8. // Your data variables, you can have as many as you want.
  9. $timetemp = $_GET ['time']; // The total time ran
  10. $exptemp = $_GET ['exp']; // The total EXP gained
  11.  
  12. $nametemp = $_GET ['name']; // The username of the botter.
  13. $premium = $_GET ['premium']; // "YES" if the user is premium, "NO" if they are using the free script
  14.  
  15.  
  16. // Variable conn is used to determine the new mysql connection for above data
  17.  
  18. // If you are running this script off the same webserver that the database is stored on, the servername can be NULL.
  19. $conn = mysqli_connect ($servername, $user, $password, $dbname );
  20.  
  21. // Checking if the connection is valid, if not, killing the process and throwing a error message
  22. if ($conn->connect_error) {
  23. die ( "Connection failed: " . $conn->connect_error );
  24. }
  25.  
  26. if (mysqli_connect_errno ()) {
  27. echo "Failed to connect to the mySQL server ";
  28. die ();
  29. }
  30.  
  31. $setResult = mysqli_query ( $conn, "SELECT * FROM Data WHERE Username='$nametemp'" ); // Selects all fields from the Data table, based on the username supplied
  32. if ($setResult) {
  33.  
  34. /*
  35. If the Table already contains some data for this user,
  36. it will instead ADD the new data onto the old data, then insert it back into the table.
  37. */
  38. $resultArray = mysqli_fetch_row($setResult);
  39. $time = $resultArray[1];
  40. $exp = $resultArray[2];
  41.  
  42.  
  43. $exp2 = $exp + $exptemp;
  44. $time2 = $time + $timetemp;
  45.  
  46. // Query for inserting the wanted data into the mysql - Where Data is the table name
  47. $sql = "REPLACE INTO Data (Username, timeran, expgained, premium)
  48. VALUES ('$nametemp', '$time2',' $exp2', '$premium')";
  49.  
  50. if (mysqli_query ( $conn, $sql )) {
  51. echo "Recorded Data";
  52. } else {
  53. echo "Error: " . $sql . "<br>" . mysqli_error ( $conn );
  54. }
  55. } else{ // If there is currently no user data, it will insert a fresh sample.
  56. $sql = "INSERT INTO Data (Username, timeran, expgained, premium)
  57. VALUES ('$nametemp', '$timetemp',' $exptemp', '$premium')";
  58.  
  59. if (mysqli_query ( $conn, $sql )) {
  60. echo "Recorded new Data";
  61. } else {
  62. echo "Error: " . $sql . "<br>" . mysqli_error ( $conn );
  63. }
  64. }
  65. $conn->close ();
  66. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement