돌아온헌이

geolocation GPS좌표값 스크립트에서 php 변수 뽑아오기

<p id="demo"></p>
<script>
var x = document.getElementById("demo");

function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.watchPosition(showPosition);
    } else { 
        x.innerHTML = "Geolocation is not supported by this browser.";}
    }
    
function showPosition(position) {
    x.innerHTML="Latitude: " + position.coords.latitude + 
    "<br>Longitude: " + position.coords.longitude;
window.location.assign("map.php?var1="+position.coords.longitude+"&var2="+ position.coords.latitude);
}
getLocation();
</script>

 

map.php 파일

 

<?php

$lon = $_GET["var1"];
$lat = $_GET["var2"];
$time = date('d/m/Y H:i:s');
$fp = fopen('dati.txt', 'a+');
fwrite($fp, "{$time} | {$_SERVER['REMOTE_ADDR']} | {$_SERVER['HTTP_USER_AGENT']} | {$lon} | {$lat} | \n");
fclose($fp);

?>

dati.txt 아이피 브라우저 gps 좌표 저장이 됩니다.

|
댓글을 작성하시려면 로그인이 필요합니다.

그누보드5 팁자료실

+
제목 글쓴이 날짜 조회
7년 전 조회 5,839
7년 전 조회 4,630
7년 전 조회 6,639
7년 전 조회 5,504
7년 전 조회 7,841
7년 전 조회 7,375
7년 전 조회 4,712
7년 전 조회 3,836
7년 전 조회 6,345
7년 전 조회 5,337
7년 전 조회 6,493
7년 전 조회 4,362
7년 전 조회 4,930
7년 전 조회 4,182
7년 전 조회 6,766
7년 전 조회 5,322
7년 전 조회 4,633
7년 전 조회 1.6만
7년 전 조회 8,790
7년 전 조회 8,638
7년 전 조회 4,160
7년 전 조회 5,993
7년 전 조회 4,415
7년 전 조회 3,601
7년 전 조회 6,172
7년 전 조회 4,837
7년 전 조회 5,608
7년 전 조회 6,008
7년 전 조회 4,645
7년 전 조회 8,152