Contact form not working

3

I have the following problems in the form I put together:

  • The form is not sent to the email.
  • After clicking the submit, pressing to reload the page, gives the conflict of "Confirm form resubmission".

Here is the Code:

<div class="form-dicas">
    <div class="sombra"></div>

    <div class="wrp-dicas clearfix">
        <div id="dicas" class="dicas">
            <img class="botao-fechar-x" src="images/botao-x.png">
            <?php
                if (isset($_POST['submit'])) {

                    unset($_POST['submit']);

                    $name        =   $_POST['name'];
                    $email       =   $_POST['email'];
                    $facebook    =   $_POST['facebook'];
                    $twitter     =   $_POST['twitter'];
                    $msg         =   $_POST['msg'];

                    $headers  = "From: ".$email."\r\n";
                    $headers .= "MIME-Version: 1.0";
                    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

                    $subject  = "Formulário de - ".$name;

                    $corpo  = "Nome: " . $name . "\n";
                    $corpo .= "Email: " . $email . "\n";
                    $corpo .= "Facebook: " . $facebook . "\n";
                    $corpo .= "twitter: " . $twitter . "\n";
                    $corpo .= "Mensagem: " . $msg . "\n";

                    $email_to = '[email protected]';
                    mail($email_to, $subject, $corpo, $headers);
                }
            ?>
            <form action="" method="post">
                <ul>
                    <li class="name">
                        <label for="name">Nome:</label>
                        <input required id="name" name="name" type="text" />
                    </li>
                    <li class="facebook">
                        <label for="facebook">Facebook (opcional):</label>
                        <input id="facebook" name="facebook" type="text" />
                    </li>
                    <li class="twitter">
                        <label for="twitter">Twitter (opcional):</label>
                        <input id="twitter" name="twitter" type="text" />
                    </li>
                    <li class="email">
                        <label for="email">E-mail:</label>
                        <input required id="email" name="email" type="text" />
                    </li>
                    <li class="msg">
                        <label for="msg">Mensagem:</label>
                        <textarea required id="msg" name="msg" type="text"></textarea>
                    </li>
                    <li class="submit">
                        <input id="send_form" type="submit" name="submit" value="Enviar" />
                    </li>
                </ul>
            </form>
        </div><!-- div wrp-dicas -->
    </div><!-- div sombra -->
</div><!-- div form-dicas -->

There is also a small jquery snippet, which I believe to be irrelevant, but here it is:

<script type="text/javascript">
    var $j = jQuery.noConflict();
    $j(document).ready(function() {

        $j(".clique-aqui").click(function() {
            $j(".form-dicas").fadeIn('slow');
        });

        $j(".botao-fechar-x").click(function() {
            $j(".form-dicas").fadeOut("slow");
        });

        $j(document).bind('keydown', function(e) { 
            if (e.which == 27) {
                $j(".form-dicas").fadeOut("slow");
            }
        }); 
    });
</script>

I'm using xampp to test this form, could you help me with what I did wrong?

Thanks!

    
asked by anonymous 26.12.2014 / 13:00

1 answer

2

The problem is with the XAMP configuration, I suggest testing on a server outside the localhost, if possible. But if you want to keep there you will have to change the settings:

PHP.INI:

  • C: \ xampp \ php \ php.ini

  • Remove ; before extension=php_openssl.dll
  • Find [mail function] and change them:
SMTP = smtp.gmail.com
smtp_port = 465
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header=Off
sendmail_from = [email protected]

sendmail.ini

  • C: \ xampp \ sendmail \ sendmail.ini

  • Edit the following lines:
smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=ssl
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=sua_senha
pop3_server=
pop3_username=
pop3_password=
[email protected]
force_recipient=
hostname=smtp.gmail.com

I think this will solve!

    
26.12.2014 / 13:53