I want to get longitude Latitude and Exact Location on login page How i merge these page in on login page only

his is My login page i want change my Webpage to Webview Android app But there is problem after login My next page didn’t open after adding header there it works fine but that time i didn’t get location data so here There are two page please merge it so i get longitude, latitude and exact location in the mean time i want to go on dashboard.php so i can get location detail and redirect with new page you can suggest me a whole new code

    <!DOCTYPE html>
    <html>
    <body onload='getLocation()'>
    </body>
    </html>
    <?php
    include('config.php');
    session_start();
    $a = $_REQUEST['username'];
    $b = $_REQUEST['password'];



        if($a=='admin' && $b=='1234')
        {

            $_SESSION["username"]=$a;
            ?>
            <script>
    var x = document.getElementById("demo");

    function getLocation() {
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(redirectToPosition);
        } else { 
            x.innerHTML = "Geolocation is not supported by this browser.";
        }
    }


    function redirectToPosition(position) {
      window.location='adminlocation.php?lat='+position.coords.latitude+'&long='+position.coords.longitude;
    }
    </script>
            <?php

        }
        else
        {

            $q = mysqli_query($con,"select * from student where username='$a'");
        $k = mysqli_fetch_array($q);

        $l = $k["password"];

        if($l==$b)
        {
            $_SESSION["sid"]=$a;
            ?>
                    <script>
    var x = document.getElementById("demo");

    function getLocation() {
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(redirectToPosition);
        } else { 
            x.innerHTML = "Geolocation is not supported by this browser.";
        }
    }

    function redirectToPosition(position) {
      window.location='studentlocation.php?lat='+position.coords.latitude+'&long='+position.coords.longitude;
    }
    </script>

            <?php

        }
        else
        {
            echo "invalid username or password";
        }
        }

    ?>
    ``
dashboard.php as follows



    <?php
    include ('config.php');
    session_start();
    $a=$_SESSION["username"];
    $lat=(isset($_GET['lat']))?$_GET['lat']:'';
    $long=(isset($_GET['long']))?$_GET['long']:'';
    $location=(isset($_GET['location']))?$_GET['location']:'';
    //IP Address
    //whether ip is from share internet
    if (!empty($_SERVER['HTTP_CLIENT_IP']))   
      {
        $ip_address = $_SERVER['HTTP_CLIENT_IP'];
      }
    //whether ip is from proxy
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))  
      {
        $ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
      }
    //whether ip is from remote address
    else
      {
        $ip_address = $_SERVER['REMOTE_ADDR'];
      }


        $r = mysqli_query($con,"insert into geo(username,DateTime,location,lat,longi,ip) values('$a',CURTIME(),'$location','$lat','$long','$ip_address')");

        if($r){
            header("location:dashboard.php");
        }

    ?> 
    php
Sponsor our Newsletter | Privacy Policy | Terms of Service