ModalBox Email将php变量传递给sms发送者

时间:2012-10-25 22:49:45

标签: php jquery email variables post

好的,所以我使用ModalBox在我的网站上创建一个电子邮件表格..但是,我需要模态框不发送电子邮件给我,而是发送给添加汽车的用户(它是汽车销售网站),所以我需要将$ email变量传递给sendmessage.php。

这就是我到目前为止所做的:

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


    $("#send").on("click", function(){
    setTimeout("$.fancybox.close()", 10);
        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>Se trimite...</em>");

            $.ajax({
                type: 'POST',
                url: 'http://automoka.ro/sendmessage.php',
                data: $("#contact").serialize(),
                success: function(data) {
                    if(data == "true") {
                        $("#contact").fadeOut("fast", function(){
                            $(this).before("<p><strong>Mesajul a fost trimis!</strong></p>");
                            setTimeout("$.fancybox.close()", 10);
                            $_POST['contact'] = $email;
                        });
                    }
                }
            });
        }
    });
});

$(document).ready(function() { $(".modalbox").fancybox(); $("#contact").submit(function() { return false; }); $("#send").on("click", function(){ setTimeout("$.fancybox.close()", 10); 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>Se trimite...</em>"); $.ajax({ type: 'POST', url: 'http://automoka.ro/sendmessage.php', data: $("#contact").serialize(), success: function(data) { if(data == "true") { $("#contact").fadeOut("fast", function(){ $(this).before("<p><strong>Mesajul a fost trimis!</strong></p>"); setTimeout("$.fancybox.close()", 10); $_POST['contact'] = $email; }); } } }); } }); });

并在php发件人中:

我做错了什么?请帮助....提前致谢!

修改: 没关系......把它搞定了!...我添加了一个隐藏在modalbox中的textarea ...并使用post将它发送到sendmessage.php。

0 个答案:

没有答案
相关问题