I am not able to save a data edit with php and mysql

0

Save working correctly

<?php include "conectar.php";
$nome="$_POST[nome]";
$sobrenome="$_POST[sobrenome]";
$email="$_POST[email]";
$cpf="$_POST[cpf]";
$dddcel="$_POST[dddcel]";
$cel="$_POST[cel]";
$dddtel="$_POST[dddtel]";
$tel="$_POST[tel]";
$nasc="$_POST[nasc]";

$sql->query ("insert into dados(nome, sobrenome, email, cpf, dddcel, cel, dddtel, tel, nasc) values ('$nome', '$sobrenome', '$email', '$cpf', '$dddcel', '$cel', '$dddtel', '$tel', '$nasc')");

header("Location: listar.php");
?>

And this is the uptade that is not working:

<?php 
include "conectar.php";   //inlui o conectar(endereco do banco)
$nome=$_POST["nome"];
$sobrenome=$_POST["sobrenome"];
$email=$_POST["email"];
$cpf=$_POST["cpf"];
$dddcel=$_POST["dddcel"];
$cel=$_POST["cel"];
$dddtel=$_POST["dddtel"];
$tel=$_POST["tel"];
$nasc=$_POST["nasc"];

$sql->query("UPDATE dados SET nome ='$nome', sobrenome ='$sobrenome', email = '$email', cpf = '$cpf', dddcel = '$dddcel', cel = '$cel', dddtel = '$dddtel', tel = '$tel', nasc = '$nasc' where cod = $cod");

header("Location: listar.php");
?>
    
asked by anonymous 22.06.2017 / 15:51

1 answer

0

The syntax is wrong:

Wrong

$nome="$_POST[nome]";

Right

$nome = $_POST["nome"];

I did not understand why you said "Save" is working, and the syntax is wrong.

    
22.06.2017 / 15:59