Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "";
- $password = "";
- $dbname="";
- $route = "";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- if (isset($_GET["LATITUDE"])) {
- $branchid = test_input($_GET["LATITUDE"]);
- echo $branchid;
- }
- if (isset($_GET["LONGITUDE"])) {
- $banch = test_input($_GET["LONGITUDE"]);
- $branch = chop($banch,".");
- // echo $branch;
- }
- if(empty($branchid)||empty($branch)){
- echo "Daaaamn boy get some value dont be so null";
- }else{
- $sq1 = "DELETE FROM `location` where route = '21'";
- if (mysqli_query($conn, $sq1)) {
- echo "<p>previous record of 21 has been deleted successfully</p>";
- } else {
- echo "<p>Error: " . $sq . "<br>" . mysqli_error($conn)."</p>";
- }
- $sq = "INSERT INTO `location`(`route`,`latitude`, `longitude`) VALUES ('$route','$branchid','$branch')";
- if (mysqli_query($conn, $sq)) {
- echo "<p>New record created successfully</p>";
- } else {
- echo "<p>Error: " . $sq . "<br>" . mysqli_error($conn)."</p>";
- }
- }
- // $fp = fopen('logs.txt','a');
- // fwrite($fp,$branchid." ".$branch." ".time()."\n");
- //
- //fclose($fp);
- mysqli_close($conn);
- function test_input($data) {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement