0
Even by clicking on the option cancel it does delete. Can you help me? This is my code:
if (($page == 'delete') && $id > 0) {
echo '<script>
var r = confirm("Deseja realmente excluir esse usuário?");
if(r != true){ return false; }else{
return true;
';
// executa o SQL para excluir
$sql = $conn->prepare('DELETE FROM registro.cadastro WHERE id= :id');
// prepara os dados
$data = array(':id' => $id);
try {
// executa o SQL
$sql->execute($data);
// Mostra a mensagem de erro
$mensagem = alert('Registro deletado.');
} catch (PDOException $e) {
// mostra a mensagem
$e->getMessage();
}
echo'}
</script>';
}
Hi Danilo. I think you’re mixing PHP and Javascript. Do you know the difference between "client side" and "server side"? Take a look here: http://answall.com/q/608/129
– Sergio
someone knows a way this making this validation?
– danilo santos
Did you see the link I suggested? Do you understand the question and answers? (I ask so we can help you )
– Sergio
First, following the previous comment, I advise checking using Javascript, and make a call to PHP sending the parameters to delete after this. Second, logical. Use parentheses like this: if ( ($page == 'delete') && ($id > 0) ) { ... }
– Jhonatan Pereira