I created a form inside my site to be sent to my email, it’s not coming in the inbox. What can it be?

Asked

Viewed 61 times

-1

https://facasozinho.com/fale.html

On the same day I uninstalled wordpress manually, so I do not know if there was conflict with the . original htacess with the other 2 files (.htacess) that contained Wordpress.

//TRECHO DE CÓDIGO
<?php
    
    if(isset($POST['email']) && !empty($_POST['email'])){
    
       $nome = addslashes($_POST['name']);
       $email = addslashes($_POST['email']);
       $mensagem = addslashes($_POST['message']);
    
    
       $to = "[email protected]";
       $subject = "Contato - Sugestão FZ";
       $body = "Nome: ".$nome. "\r\n".
            "Email: ".$email."\r\n".
            "Mensagem ".$mensagem;
    
       $header = "From:[email protected]"."\r\n". 
                "Reply - To:".$email."\e\n".
                "x=Mailer:PHP/".phpversion();
   
       if(mail($to,$subject,$body,$header))
       {    
          echo("Email enviado com sucesso!");
        } else {
          echo("O Email não pode ser enviado");
        }
    
    }
    
?>

Note: If you can answer me in a way that I learn how to solve and not have the answer in hand I would be grateful.

1 answer

1


The mistake is in the if, see that no information is returned, Sponse is empty, indicating that it does not enter this IF.

It turns out you misnamed the array $_POST, you typed $POST['email'] instead of $_POST['email'], will probably work when correcting:

if(isset($_POST['email']) && !empty($_POST['email'])){

  • @Matheus-gamisz if the answer solved your problem, thank you if you mark it as accepted

  • Another common oversight when learning a new language, do you think using a language-specific IDE like PHP Storm would help or is that common? Thanks in advance.

  • My friend, writing variable names is a common oversight for everyone, especially if you are not using an IDE, rest assured. But, using an IDE helps a lot in code productivity and quality. I’ve been using PHP Storm for a couple of years now, but for many years before I used Netbeans to work with PHP, you’ll be fine with any of them.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.