简体   繁体   English

联系表格接收来自网站的空邮件

[英]contact form receiving empty mail from website

i bought me a template for my website where also a finished cotact form was with it . 我为我的网站买了一个模板,上面还有一张完工的彩图。

the think is that there is just a javascript text code so no php script . 认为只有一个javascript文本代码,所以没有php脚本。 i wrote a php text by my self, and it is working but the thing is that if i click on send on my website , i will receive an email but it is empty . 我自己写了一个php文本,它可以正常工作,但事实是,如果我单击我网站上的send,我会收到一封电子邮件,但它是空的。 so name , email adress etc. is not transmitting. 因此名称,电子邮件地址等不会传输。

jQuery(document).ready(function($) {

errors = new Array();
form = $('#contact');

form.submit(function() {
    $('#loading').fadeIn();
    $('#error, #success').hide();
    if(validate()) { 
        submission();
        return false;
    } else {
        $('#loading').hide();
        $('#error, #results').fadeIn();
        return false;
    };
})

function validate() {
    errors.length=0;

    $('.req').each(function() {
        val = $(this).val();
        id = $(this).attr('id');
        if(!val) {
            errors.push(id);
        }
    })

    if(errors.length === 0) {
        return true;
    } else {
        $.each(errors, function(index, value) {
            $('#' + value).addClass('error');
        });
        return false;
    }
}

function submission() {
    var name = $("input#name").val();  
    var email = $("input#email").val();  
    var phone = $("input#phone").val();
    var comments = $("#comments").val();
    var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&comments=' + comments;  
    //alert (dataString);return false;  
    $.ajax({  
      type: "POST",  
      url: "senden.php",  
      data: dataString,  
      success: function() {  
        $('#results, #success').fadeIn();
        $('#loading').hide();
      }  
    });  
    return false;
}

})

thats the script i put all the script and php part icluding the html form into a jsfiddle file. 多数民众赞成在脚本,我把所有的脚本和PHP的一部分,包括html形式到jsfiddle文件中。 i hope ya could help me. 我希望你能帮助我。 jsfiddle jsfiddle

Did you even look at the PHP script you posted? 您甚至没有看过您发布的PHP脚本? You are setting the variables $name , $email , and $comments , but then you are using $nachricht and $email (which do not exist) when you are sending the mail :\\ 您正在设置变量$name$email$comments ,但是在$email ,您正在使用$nachricht$email (不存在):\\

$data=$_POST;
$name=$data['name'];
$email=$data['email'];  
$comments=$data['comments'];   

Those variables are not used here: 这些变量不在此处使用:

mail('it@awesom-media.de', 'E-Mail von der Webseite', $nachricht, 'From: ' . $email);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM