By clicking on my submit, the php function is opening my file

0

I have the following file called test3.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 submit, this function is called in my cadastros.php 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 the submit button, the cadastros.php file opens and displays the following:

    
asked by anonymous 30.10.2018 / 23:07

1 answer

0

The path specified in the address bar is from the file on the machine, so it does not run the file on the server.

You need to use the localhost path defined by xamp.

Example : localhost / cadastro.php

    
30.10.2018 / 23:29