Update information

0
<?php

session_start();

$mysqli = new mysqli("localhost", "root", "", "lista"); 
if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
}
$id = $_POST['id'];
$agencia = $_POST['agencia'];
$depa =  $_POST['departamento'];
$area =  $_POST['area'];
$nombre =  $_POST['nombre'];
$ext     =  $_POST['extencion'];    

$sql = $mysqli->query("update lista set id='$id', agencia='$agencia', departamento=$depa, area='$area', nombre='$nombre',extencion='$ext' where id='$id'");
?>  

<SCRIPT LANGUAGE="javascript"> 
     alert("Contacto Actualizado"); 
</SCRIPT> 
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=listar.php">
    
asked by Luis Daniel Esquivel Maldonado 03.03.2018 в 20:27
source

1 answer

0

I saw several details in your code and I passed the following script to you; give it a try and stay tuned for your comments:

<?php

session_start();

$conexion = new mysqli("localhost", "root", "", "lista"); 
if ($conexion->connect_error) {
die("Connection failed: " . $conexion->connect_error);
} 

$id = $_POST['id']; $agencia = $_POST['agencia']; $depa = $_POST['departamento']; $area = $_POST['area']; $nombre = $_POST['nombre']; $ext = $_POST['extencion'];

$sql = "UPDATE lista SET id='".$id."', agencia='".$agencia."', departamento='".$depa."', area='".$area."', nombre='".$nombre."',extencion='".$ext."' where id='".$id"'";

if($conexion->query($sql)){
    echo "Modificado con éxito";
}else{
    echo "No modificado";
}

How you can notice the syntax for your variables should be '".$variable."'

I also recommend that your variable that stores the connection does not name the same as the driver you are using, that is to say mysqli, I will change it for $ connection and it should continue working.

    
answered by 03.03.2018 / 20:35
source