2
good night!
How do I prevent registration with the same information?
Currently my "processa.php" is like this, and I wanted to include the function mentioned above...
<?php
session_start();
include_once ("conexao.php");
$nome = filter_input($INPUT_POST, 'nome', FILTER_SANITIZE_STRING);
$email = filter_input($INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);
$senha = filter_input($INPUT_POST, 'senha', FILTER_SANITIZE_STRING);
$cargo = filter_input($INPUT_POST, 'cargo', FILTER_SANITIZE_STRING);
$setor = filter_input($INPUT_POST, 'setor', FILTER_SANITIZE_STRING);
$result_usuario = "INSERT INTO usuarios (nome, email, senha, cargo, setor, created) VALUES ('$nome', '$email', '$senha', '$cargo', '$setor', NOW())";
$resultado_usuario = mysqli_query($conn, $result_usuario);
if(mysqli_insert_id($conn)){
$_SESSION['msg'] = "<p style='color:green;'>Usuário cadastrado com sucesso</p>";
header("Location: cadastrar-usuario.php");
}else{
$_SESSION['msg'] = "<p style='color:red;'>Usuário não foi cadastrado com sucesso</p>";
header("Location: cadastrar-usuario.php");
}
?>
I think that before you should define what would be unique (name, email), usually set the email as unique, because other information may vary. Then you check if the email already exists as a condition to register or not.
– Sam