I am trying to update one of my tables in my database. To identify the row that I am going to update, I use as my base for the search an email that I enter in a form before requesting that I enter the rest of the data to update. The problem is that after performing the operation it throws an error and I have not been able to find my fault. On this site I use:
Page on which I request the data.
A PHP connection.
A PHP that processes the update.
The database.
Next I will illustrate the process and I will have a code snippet
Screen in which I request and enter the data.
form code
<label>Localidad</label>
<input type="text" name="labelLocalidad1" required/>
</div>
<div class="form-element">
<label>Direccion</label>
<input type="text" name="labelDireccion1" required/>
</div>
<div class="form-element">
<label>Codigo Postal</label>
<input type="text" name="labelPostal1" pattern="[a-zA-Z0-9]+" required/>
</div>
<div class="form-element">
<label>Providencia</label>
<input type="text" name="labelProvidencia1" pattern="[a-zA-Z0-9]+" required/>
</div>
<div class="form-element">
<label>Numero de telefono</label>
<input type="number" name="labeltelefono1" pattern="[a-zA-Z0-9]+" required/>
</div>
<button type="submit" name="PAGO" value="PAGO">Registrar direccion</button>
</form>
Conection code
<?php
$host = "localhost";
$user = "root";
$clave = "";
$bd = "usuarios";
$conectar = mysqli_connect($host,$user,$clave,$bd);
?>
php
<?php
require 'conexion.php';
$idusuario= session_id();
$localidad = $_POST['labelLocalidad1'];
$direccion = $_POST['labelDireccion1'];
$postal = $_POST['labelPostal1'];
$providencia = $_POST['labelProvidencia1'];
$telefono = $_POST['labeltelefono1'];
$correoentrega = $_POST['labelcorreo1'];
$actualizar =("UPDATE datosentrega set localidad='$localidad',direccion='$direccion',postal=$postal,providencia='$providencia',telefono='$telefono' WHERE correoentrega='$correoentrega'");
$query = mysqli_query($conectar,$actualizar);
if($query){
echo "<script> alert('Datos registrados');
</script>";
}else{
echo "<script> alert('Error favor de revisar el codigo XD');
</script>";
}