I tried putting “isset()”, i tried putting null, i researched every single solution and NOTHING works.
It says that:
Warning: Undefined array key “GoogleMaps” in C:xampphtdocspaonlineconfig_novapadeiras.php on line 11
For context: My idea is that you are suppost to be able to send a full link from any bakery from Google Maps, but that is what is giving me problems.
This is my code on php :
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['enviar'])) {
$conn= mysqli_connect('localhost', 'root', '', 'paonline') or die("Falho de connexao:" .mysqli_connect_error());
if(isset($nome) && isset($localidade) && isset($padeiramap));
$nome = $_POST['nome'];
$localidade = $_POST['localidade'];
$padeiramap = $_POST['GoogleMaps'];
return $GoogleMaps[$padeiramap] ?? null;
$sql= "INSERT INTO 'padeiras' ('nome','localidade','GoogleMaps') VALUES ('$nome','$localidade','$padeiramap')";
$query = mysqli_query($conn,$sql);
if($query) {
echo "Dados enviados! Agora o nosso equipo revisara se a sua padeira tem todo o preciso para ser colocada em nossa web.";
}
else {
echo "Aconteceu um erro! Revise se tem introducido bem os dados na sua padeira ou espere um tempo e volte a temtar registrar a sua padeira.";
}
}
?>
and this is my code in the html form:
<fieldset>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method='POST'>
<div class="form-group">
<center><label>Nome da padeira</label></center>
<center><input type="text" name="nome" id="nome" required></center>
</div>
<div class="form-group">
<center><label>Localidade</label></center>
<center><input type="radio" name="localidade" value="Murtosa" required>Murtosa</center>
<center><input type="radio" name="localidade" value="Estarreja" required>Estarreja</center>
<center><input type="radio" name="localidade" value="Ovar" required>Ovar</center>
</div>
<div class="form-group">
<center><label>Link no Google Maps:</label></center>
<center><input type="url" name="padeiramap" id="padeiramap" required></center>
</div>
<center><div class="form-group">
<input type="submit" id="Enviar" name="enviar">
<input type="reset" id="Reiniciar" name="reiniciar">
</div></center>
</form>
</fieldset>
</body>
</html>
This are two separated files on the same folder by the way.
And please, before you ask:
- NO, i do not know what do you mean with having “MySQL installed”. If you are talking about hacing Apache and MySQL started in XAMPP them yes, i have them both.
- YES, i have removed the $bd and $link connections so it not longers causes conflict.
- NO, I do not know what do you mean with my code been vulnerable to SQL injections, is not suppost to be a public web.
- Avoid downvoting my question. I am asking for help with something very important for me and i would not like it if i got spitted on my face.