0
I have a file where people write in the camps:
<div class="banner-bot" >
<div class="container">
<h2>Registar</h2>
<p>Preenche os dados para criar a tua conta. Quando te registares irá ser enviado um email para confirmares a conta. </p>
<br>
</div>
<form name="registarUtilizador" action="Inserir/InserirUtilizador.php" onsubmit="return validarRegisto()" method="POST">
<div class="register-box">
<div class="text">
<input type="text" placeholder="Nome Completo" required="" name="nomeCompleto" id="nomeCompleto" maxlength="99"/>
<br>
<br>
<input type="text" placeholder="Email" required="" name="email" id="email" maxlength="99"/>
<br>
<br>
<input type="text" placeholder="Confirme o seu Email" required="" name="emailConfirmar" id="emailConfirmar" maxlength="99"/>
<br>
<br>
<input type="password" placeholder="Password" required="" name="pass" id="" maxlength="20"/>
<br>
<br>
<input type="password" placeholder="Confirme a sua Password" required="" name="passConfirmar" id="passConfirmar" maxlength="20"/>
<br>
<br>
</div>
<div class="text-but">
<input type="submit" name="submit" value="Confirmar"/>
</div>
</div>
</form>
And when the Submit button is clicked, the format of the email will be checked, if the email already exists in the database... all in another file. And what I wanted was to create a div or an Alert, that is, a way to inform that the email is already registered and return to the registration page. And the same when the registration is successfully done. Return to the main page warning the user that your account has been successfully registered.
Verification code:
<?php require '../functions.php'; ?>
<body>
<?php
$nomeCompleto = $_POST["nomeCompleto"];
$email = $_POST["email"];
$pass = $_POST["pass"];
$options = [
'cost' => 12,
];
$pass = password_hash($pass, PASSWORD_BCRYPT, $options);
// Create connection
$conn = db_connect();
$sql = "INSERT INTO utilizadores (nomeCompleto, email, pass)
VALUES ('$nomeCompleto', '$email', '$pass')";
if ($conn->query($sql) === TRUE) {
// Retornar para a página index e avisar o utilizador que foi registado com sucesso
header("Location: ../index.php");
} else {
//Retorar para a página registar e avisar o utilizador que o email já está inserido/registado
header("Location: ../registar.php");
}
$conn->close();
?>
I believe there are two ways to do this. The first is with Ajax, the second is on the page register you have a get prepared and do something like this:
Location: ../registar.php?value=fail
– Raizant