Form Validation - PHP

0

I'm trying to validate an email for submitting a form at , but it is difficult. My code is below, where am I going wrong?

 $subject2 = utf8_decode ('Formulário 2016 - PRE-CADASTRO');
 $body2 = $mensagem_confirmacao;

 if (filter_var($mail, FILTER_VALIDATE_EMAIL)) 
 {      
     if (mail($to, $subject, $body, $headers)) {    
         mail($mail, $subject2, $body2, $headers);
         echo "<p>Inscrição enviada com sucesso!</p>";
    } else {
         echo "<p>Erro no envio, Houve algum erro no envio.Tente Novamente ";
    }

 } else { 
     echo "<p>E-mail ".$mail." inválido <a href='inscreva-se.php'>Houve algum erro no envio.Tente Novamente</a>!</p>"; 
 }  
    
asked by anonymous 15.12.2015 / 18:52

1 answer

0

I'm not exactly sure what your problem is, but mail if () is duplicated. The correct one would look like this:

if ( mail($to, $subject, $body, $headers) ) 
{    
   echo "<p>Inscrição enviada com sucesso!</p>";
}
else
{
   echo "<p>Erro no envio, Houve algum erro no envio.Tente Novamente</p> ";
}
    
15.12.2015 / 19:11