Variables are not receiving input value in PHP [closed]

2

I have this form to send messages to the email:

 <form action="contato.php" name="sentMessage" id="contactForm" novalidate>
                    <div class="row">
                        <div class="col-md-6 wow fadeInLeft" data-wow-duration="2s" data-wow-delay="600ms">
                            <div class="form-group">
                                <input type="text" name="name" class="form-control" placeholder="Nome *" id="name" required data-validation-required-message="Please enter your name.">
                                <p class="help-block text-danger"></p>
                            </div>
                            <div class="form-group">
                                <input type="email" name="email" class="form-control" placeholder="Email *" id="email" required data-validation-required-message="Please enter your email address.">
                                <p class="help-block text-danger"></p>
                            </div>
                            <div class="form-group">
                                <input type="tel" name="phone" class="form-control" placeholder="Telefone *" id="phone" required data-validation-required-message="Please enter your phone number.">
                                <p class="help-block text-danger"></p>
                            </div>
                        </div>
                        <div class="col-md-6 wow fadeInRight" data-wow-duration="2s" data-wow-delay="600ms">
                            <div class="form-group">
                                <textarea class="form-control" name="message" placeholder="Mensagem *" id="message" required data-validation-required-message="Please enter a message."></textarea>
                                <p class="help-block text-danger"></p>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                        <div class="col-lg-12 text-center wow zoomIn" data-wow-duration="1s" data-wow-delay="600ms">
                            <div id="success"></div>
                            <button type="submit" class="btn btn-primary">Enviar</button>
                        </div>
                    </div>
                </form>

The action of the form sends to the same page, and at the top of the page I put the following code:

<?php

   $nome = $_POST['name'];
   $email = $_POST['email'];
   $telefone = $_POST['phone'];
   $mensagem = $_POST['message'];

   $to = "[email protected]";

   $subject = "Email do Site";

   $headers = "De:";

   $corpo  = "Nome: ".$nome."<BR>\n";
   $corpo .= "Email: ".$email."<BR>\n";
   $corpo .= "Telefone: ".$telefone."<BR>\n";
   $corpo .= "Mensagem: ".$mensagem."<BR>\n";

   Mail($to, $subject, $corpo, $headers);

   ?>

You are sending mail normally, but the email body is not reaching variable values.

    
asked by anonymous 18.08.2017 / 18:37

2 answers

4

The method=POST attribute is missing, change to this:

 <form method="POST" action="contato.php" name="sentMessage" id="contactForm" novalidate>
    
18.08.2017 / 18:40
1

Try to put method="POST" in the form tag:

<form action="contato.php" name="sentMessage" id="contactForm" method="POST" novalidate>
    
18.08.2017 / 18:41