为什么我的联系表格不起作用?

时间:2014-06-27 10:27:36

标签: javascript php jquery html fancybox

我试图在网站上添加一个与Jquery和Fancybox联系的表单。

一切似乎都表现不错,弹出动画还可以,邮件似乎已经发出,但我没有收到任何邮件:(

有人可以帮我理解问题所在吗?

修改

- 我已检查过我的垃圾邮件和垃圾邮件文件夹

- 这是网站链接:lacouleurdurendezvous.fr

- 有人谈到服务器配置错误,它是什么?

修改

- 这似乎是服务器故障......我试图联系我的网络主机...

以下是我调用脚本的方式:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js" type="text/javascript"></script>
<script src="Ressources/retour.js"></script>
<script src="Ressources/testhead.js"></script>
<script type="text/javascript" src="fancybox/jquery.fancybox.js?v=2.0.6"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script><script type="text/javascript" src="fancybox/jquery.fancybox.js?v=2.0.6"></script>

以下是html代码:

<li id="menu"><a class="modalbox" href="#inline">Contactez Nous</a></li>

             <!-- hidden inline form -->
<div id="inline">
    <h2>Envoyez nous un email</h2>

    <form id="contact" name="contact" action="#" method="post">
        <label for="email">E-mail</label>
        <input type="email" id="email" name="email" class="txt">
        <br>
        <label for="msg">Message</label>
        <textarea id="msg" name="msg" class="txtarea"></textarea>

        <button id="send">Envoyer</button>
    </form>
</div>

<!-- basic fancybox setup -->
<script type="text/javascript">
    function validateEmail(email) { 
        var reg = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
        return reg.test(email);
    }

    $(document).ready(function() {
        $(".modalbox").fancybox();
        $("#contact").submit(function() { return false; });


        $("#send").on("click", function(){
            var emailval  = $("#email").val();
            var msgval    = $("#msg").val();
            var msglen    = msgval.length;
            var mailvalid = validateEmail(emailval);

            if(mailvalid == false) {
                $("#email").addClass("error");
            }
            else if(mailvalid == true){
                $("#email").removeClass("error");
            }

            if(msglen < 4) {
                $("#msg").addClass("error");
            }
            else if(msglen >= 4){
                $("#msg").removeClass("error");
            }

            if(mailvalid == true && msglen >= 4) {
                // if both validate we attempt to send the e-mail
                // first we hide the submit btn so the user doesnt click twice
                $("#send").replaceWith("<em>en cours d'envoi</em>");

                $.ajax({
                    type: 'POST',
                    url: 'sendmessage.php',
                    data: $("#contact").serialize(),
                    success: function(data) {
                        if(data == "true") {
                            $("#contact").fadeOut("slow", function(){
                                $(this).before("<p><strong>Merci de votre interet, bonne journee</strong></p>");
                                setTimeout("$.fancybox.close()", 4000);
                            });
                        }
                    }
                });
            }
        });
    });
</script>

和php:

 <?php
$sendto   = "hello@tiphainebuccino.com";
$usermail = $_POST['email'];
$content  = nl2br($_POST['msg']);

$subject  = "La Couleur Du Rendez Vous";
$headers  = "From: " . strip_tags($usermail) . "\r\n";
$headers .= "Reply-To: ". strip_tags($usermail) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html;charset=utf-8 \r\n";

$msg  = "<html><body style='font-family:Arial,sans-serif;'>";
$msg .= "<h2 style='font-weight:bold;border-bottom:1px dotted #ccc;'>New User Feedback</h2>\r\n";
$msg .= "<p><strong>Sent by:</strong> ".$usermail."</p>\r\n";
$msg .= "<p><strong>Message:</strong> ".$content."</p>\r\n";
$msg .= "</body></html>";


if(@mail($sendto, $subject, $msg, $headers)) {
    echo "true";
} else {
    echo "false";
}

?> 

0 个答案:

没有答案