0
phpで名前、緯度、経度、電話番号の値を投稿したい。フロントエンドとしてhtmlを使用して詳細を収集しています。PHPで緯度と経度を投稿できませんが、名前を投稿できます、電話番号。PHPで私の場所の緯度と経度を投稿する方法は?htmlを使用してphpで私の場所の緯度と経度を投稿するには?
<html>
<body>
<form method="post" action="try2.php">
First name:<input type="text" name="first_name" ><br>
Phone:<input type="tel" name="phone" >
<p><button onclick="geoFindMe()">Show my location</button></p>
<div id="out"></div>
<script>
function geoFindMe() {
var output = document.getElementById("out");
if (!navigator.geolocation){
output.innerHTML = "<p>Geolocation is not supported by your
browser</p>";
return;
}
function success(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
output.innerHTML = '<p>Latitude is ' + latitude + '° <br>Longitude is ' + longitude + '°</p>';
var img = new Image();
img.src = "https://maps.googleapis.com/maps/api/staticmap?center=" +
latitude + "," + longitude + "&zoom=13&size=300x300&sensor=false";
output.appendChild(img);
}
function error() {
output.innerHTML = "Unable to retrieve your location";
}
output.innerHTML = "<p>Locating…</p>";
navigator.geolocation.getCurrentPosition(success, error);
}
</script>
<input type="submit" value="submit" required>
</form>
Php code:
<?php
$first_name=$_POST["first_name"];
$longitude=$_POST["longitude"];
$latitude=$_POST["latitude"]
$phone=$_POST["phone"];
echo "$latitude";
?>
PHPはどこですか? – Andreas
フォームの入力テキストタイプを非表示フィールドとして追加し、これらの非表示フィールドに割り当てられた緯度と経度の値をPHPのsubmitに送信します。例えば、 –
私のHTMLページから緯度を取得したいのですが、直接挿入はありません。取得された緯度は、post method.howそれは@Nareshクマ –