돌아온헌이

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,886
7년 전 조회 4,686
7년 전 조회 6,689
7년 전 조회 5,552
7년 전 조회 7,899
7년 전 조회 7,431
7년 전 조회 4,756
7년 전 조회 3,896
7년 전 조회 6,396
7년 전 조회 5,375
7년 전 조회 6,546
7년 전 조회 4,402
7년 전 조회 4,977
7년 전 조회 4,226
7년 전 조회 6,807
7년 전 조회 5,365
7년 전 조회 4,665
7년 전 조회 1.6만
7년 전 조회 8,849
7년 전 조회 8,681
7년 전 조회 4,200
7년 전 조회 6,070
7년 전 조회 4,451
7년 전 조회 3,643
7년 전 조회 6,206
7년 전 조회 4,872
7년 전 조회 5,647
7년 전 조회 6,049
7년 전 조회 4,682
7년 전 조회 8,192