Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "";
  4. $password = "";
  5. $dbname="";
  6. $route = "";
  7.  
  8. // Create connection
  9. $conn = mysqli_connect($servername, $username, $password, $dbname);
  10. // Check connection
  11. if (!$conn) {
  12. die("Connection failed: " . mysqli_connect_error());
  13. }
  14. if (isset($_GET["LATITUDE"])) {
  15. $branchid = test_input($_GET["LATITUDE"]);
  16. echo $branchid;
  17. }
  18. if (isset($_GET["LONGITUDE"])) {
  19. $banch = test_input($_GET["LONGITUDE"]);
  20.  
  21. $branch = chop($banch,".");
  22. // echo $branch;
  23. }
  24.  
  25.  
  26. if(empty($branchid)||empty($branch)){
  27. echo "Daaaamn boy get some value dont be so null";
  28. }else{
  29. $sq1 = "DELETE FROM `location` where route = '21'";
  30. if (mysqli_query($conn, $sq1)) {
  31. echo "<p>previous record of 21 has been deleted successfully</p>";
  32. } else {
  33. echo "<p>Error: " . $sq . "<br>" . mysqli_error($conn)."</p>";
  34. }
  35. $sq = "INSERT INTO `location`(`route`,`latitude`, `longitude`) VALUES ('$route','$branchid','$branch')";
  36. if (mysqli_query($conn, $sq)) {
  37. echo "<p>New record created successfully</p>";
  38. } else {
  39. echo "<p>Error: " . $sq . "<br>" . mysqli_error($conn)."</p>";
  40. }
  41. }
  42. // $fp = fopen('logs.txt','a');
  43. // fwrite($fp,$branchid." ".$branch." ".time()."\n");
  44. //
  45. //fclose($fp);
  46. mysqli_close($conn);
  47. function test_input($data) {
  48. $data = trim($data);
  49. $data = stripslashes($data);
  50. $data = htmlspecialchars($data);
  51. return $data;
  52. }
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement