-2
I made this code to register a client in a website db. The code is coming back as if the field is empty.
Can someone tell me if I’ve done something wrong??
PHP
?>
session_start();
include('conect.php');
// RECEBE O SINAL DO BOTAO
if(isset($_POST['btn_cad_cli'])){
// CHECA SE OS CAMPOS FORAM PREENCHIDO
if(empty($_POST['nome_cli']) || empty($_POST['sobnome_cli']) ||
empty($_POST['email_cad_cli']) || empty($_POST['senha_cad_cli'])) {
// SE NAO. VOLTA PARA A PAGINA E ENCERRA SESSAO
Header('Location: ../cadastro_cli.php');
exit();
}else{
// CRIA AS VARIAVEIS
$nome = htmlentities($_POST['nome_cli']);
$sobNome = htmlentities($_POST['sobnome_cli']);
$email = htmlentities($_POST['email_cad_cli']);
$senha = htmlentities($_POST['senha_cad_cli']);
// DA UM INSERT NA TABELA
$mysqli->query("insert into login_cli values('','$nome','$sobNome','$email','$senha')");
echo $mysqli->error;
if ($mysqli->num_rows > 0){
Header("Location:../index.php");
exit();
}else{
Header('Location: ../cadastro_cli.php');
exit();
}
}
}
Well, the first field of
values
SQL is empty. Why?– Woss
This is the field where you will generate the table ID. this as auto_increment
– rogerio
It is not better to specify default in the first field?
"insert into login_cli values(DEFAULT, '$nome', '$sobNome', '$email', '$senha')"
– anonimo