0
I have the following file called teste3.php:
<form action="cadastros.php" method="post">
<label for="latitude" hidden>Latitude:</label>
<input id="latMap" hidden name="latitude"/>
<label for="longitude" hidden>Longitude:</label>
<input id="lngMap" hidden name="longitude"/>
<input type="hidden" name="acao" value="inserir">
<input type="submit">
</form>
When I click on Submit, this function is called in my.php register file.:
if(isset($_POST['acao'])){
if($_POST['acao'] == "inserir"){
cadastraLatLong();
}
}
function abrirBanco(){
$conexao = new mysqli("localhost", "root", "", "cademeupet");
return $conexao;
}
function cadastraLatLong(){
$latitude = $_POST['latitude'];
$longitude = $_POST['longitude'];
$banco = abrirBanco();
$sql = "INSERT INTO marcadores (id, descricao, lat, lng, tipo) VALUES (NULL, 'teste', '$latitude', '$longitude', 'testetipo')";
$banco->query($sql);
$banco->close();
header('Location: teste3.php');
}
When I click on the Submit button, the.php register file opens and shows the following:
Absolute certainty that PHP is installed on your machine?
– Luis Alberto Batista
yes, I use xampp, it installs php, I can also access phpmyadmin...
– veroneseComS
When I give php -v, PHP 7.2.10 is shown
– veroneseComS
is open with <?php
– veroneseComS