Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
1,156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. <?php
  2. $dbusername = 'SET_UP_YOUR_OWN';
  3. $dbpassword = 'SET_YOUR_OWN_PASSWORD';
  4. $database = 'CREATE_YOUR_OWN';
  5. $dbhost = '10.0.0.102';
  6. //
  7. $connection = mysqli_connect("$dbhost", "$dbusername", "$dbpassword", "$database");
  8. //
  9. if (mysqli_connect_errno())
  10. {
  11. echo "Failed to connect: " . mysqli_connect_error() . "\n";
  12. }
  13. else
  14. {
  15. if (!empty($_POST))
  16. {
  17. // The rawurldecode undoes the llEscapeURL, BUT, it's already done automatically.
  18. // However, we've also got the problem of single-quote-marks in a SQL statement.
  19. // In SQL, the single-quote-mark is escaped by duplicating it (i.e., it escapes itself).
  20. //
  21. //$time = str_replace("'", "''", rawurldecode($_POST['time']));
  22. //$uuid = str_replace("'", "''", rawurldecode($_POST['uuid']));
  23. //$username = str_replace("'", "''", rawurldecode($_POST['username']));
  24. //$displayname = str_replace("'", "''", rawurldecode($_POST['displayname']));
  25. //$distance = str_replace("'", "''", rawurldecode($_POST['distance']));
  26. //$direction = str_replace("'", "''", rawurldecode($_POST['direction']));
  27. //$height = str_replace("'", "''", rawurldecode($_POST['height']));
  28. //
  29. $time = str_replace("'", "''", $_POST['time']);
  30. $uuid = str_replace("'", "''", $_POST['uuid']);
  31. $username = str_replace("'", "''", $_POST['username']);
  32. $displayname = str_replace("'", "''", $_POST['displayname']);
  33. $distance = str_replace("'", "''", $_POST['distance']);
  34. $direction = str_replace("'", "''", $_POST['direction']);
  35. $height = str_replace("'", "''", $_POST['height']);
  36. //
  37. $sql = "INSERT INTO `vislog` (`time`, `uuid`, `username`, `displayname`, `distance`, `direction`, `height`) VALUES ('$time', '$uuid', '$username', '$displayname', '$distance', '$direction', '$height')";
  38. //
  39. $result = mysqli_query($connection, $sql);
  40. //
  41. if ($result)
  42. {
  43. echo "Fields added.\n";
  44. }
  45. else
  46. {
  47. echo "Error, issue with adding.\n";
  48. }
  49. }
  50. else
  51. {
  52. echo "A POST was not received.\n";
  53. }
  54. }
  55. mysqli_close($connection);
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement