i'm trying to update a value on mysql database, but i cant do it, i'm receiving succefully the data from the table, but on update it says 'connection error' i don't know what i'm missing
Panel.php
<?php
require_once 'funciones/mysql.php';
$lista = $conexion->query("SELECT id, Nombre, apellidoPaterno FROM bomberos");
if ($lista->num_rows > 0) {
while ($row = $lista->fetch_assoc()) {
echo "id: " . $row["id"] . " - Name: " . $row["Nombre"] . " " . $row["apellidoPaterno"] . "<br>";
?>
<table class="table table-bordered">
<tr>
<td>
<img src='images/bomberos/<?php echo $row['id']; ?>.jpg' height="10%" width="10%" style="opacity: 0.5;"/><br /><?php echo $row['Nombre'] . " " . $row["apellidoPaterno"]; ?>
<br />
<div class="icon-container">
<form method="post" action="funciones/disponible.php">
<input type="hidden" name="idBombero" value="<?php echo $row['id']; ?>">
<button type="submit"></button>
</form>
</div>
</td>
</tr>
</table>
<?php
}
} else {
echo "0 Resultados";
}
$conexion->close();
?>
mysql.php
<?php
//Datos de la conexion
$servidor = "localhost";
$usuario = "root";
$contraseña = "";
$basedatos = "sidesp";
//crear conexion
$conexion = new mysqli($servidor, $usuario, $contraseña, $basedatos);
//revisar conexion
if ($conexion->connect_error) {
die("conexion fallida: " . $conexion->connect_error);
}
?>
disponible.php
<?php
require_once 'mysql.php';
$consulta = "UPDATE 'estados' SET 'estado'='1' WHERE 'id'='".$_REQUEST['idBombero']."'";
if ($conexion->query($consulta) === true) {
return "Exito!";
}else{
return "Fallo!";
}
and... what's the best way to secure all of it?, i mean anti sql injections or decoding