Talk galley blz? I am a beginner in development and I have a problem, I have a form (HTML) that sends data to a PHP file and registers it in the database.
What I need is: When you successfully record the data, display a custom alert on the "index" page (the one with the form) in JQUERY ( link ), I have tried in several ways but I have not been able to. Someone help me plzzz.
HTML:
<form action="cadastrar.php" method="post" class="form-inline" role="form">
<div class="form-group">
<label class="sr-only" for="email">Email address</label>
<input type="email" name="email" class="form-control" id="email" placeholder="Escreva o seu e-mail">
</div>
<button type="submit" class="btn btn-info">Cadastrar</button>
</form> </div>
php:
$sql = "INSERT INTO users (email)
VALUES ('$email')";
if ($conn->query($sql) === TRUE) {
$var = $var = "<script language= 'JavaScript'>
location.href='index.html'
</script>";
echo $var;
}
else {
echo "Esse email ja esta cadastrado";
}
$conn->close();
?>
PS: I shortened the code.
PS2: I know I could do with ajax, but I have no idea how.