돌아온헌이

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,900
7년 전 조회 4,710
7년 전 조회 6,712
7년 전 조회 5,565
7년 전 조회 7,937
7년 전 조회 7,445
7년 전 조회 4,779
7년 전 조회 3,910
7년 전 조회 6,407
7년 전 조회 5,390
7년 전 조회 6,569
7년 전 조회 4,418
7년 전 조회 5,000
7년 전 조회 4,242
7년 전 조회 6,831
7년 전 조회 5,385
7년 전 조회 4,681
7년 전 조회 1.6만
7년 전 조회 8,893
7년 전 조회 8,715
7년 전 조회 4,222
7년 전 조회 6,116
7년 전 조회 4,463
7년 전 조회 3,658
7년 전 조회 6,228
7년 전 조회 4,892
7년 전 조회 5,684
8년 전 조회 6,063
8년 전 조회 4,703
8년 전 조회 8,212