0
What I need to do is when the email is not valid send from the javascript alert wanted to show a message above the form in question that showed the email was invalid!
HTML CODE
<input type="email" class="form-control" name="email" id="email"
placeholder="Email" data-rule="email" data-msg="Introduza um email
válido"REQUIRED />
<div class="validation"></div>
</div>
PHP validation
if(isset($_POST["contact"]))
{
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$novocontacto = "insert into contacto(nomecompleto, email, assunto,
mensagem) VALUES ('$nomecomp', '$email', '$assunto' , '$mensagem')";
$novocontacto_run = mysqli_query($conn,$novocontacto);
echo
'<script type="text/javascript">alert("Mensagem enviada com sucesso!")
</script>';
}
else
{
echo '<script type="text/javascript">alert("Email inválido")</script>';
}
}
Use a form validator in Javascript - https://jqueryvalidation.org/email-method/
– Wilson Faustino
I’m a little lost right now because I’m trying to have my shoes safe and I don’t know if I’m doing it the right way! I think I really need to filter with php so I can later insert my values into the database!!
– AlmostDone