Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
空字段php提交与其他脚本的链接_Php_Submit - Fatal编程技术网

空字段php提交与其他脚本的链接

空字段php提交与其他脚本的链接,php,submit,Php,Submit,我有一个在线问卷,我已经链接了一个提交表单,用来将用户的信息和结果发送到我的电子邮件中。很好 现在唯一的问题是,人们可以在不填写个人信息的情况下提交测验结果 如果你能在这方面帮助我,这将是奇妙的,我想,它的人必须完成他们的信息(姓名,电子邮件等)提交结果=) 我真的很感谢你抽出时间 这是我的Js,其中#quesForm是结果,#responseMessage是需要发送的其他信息: $(function() { $('#quesForm').on('submit',function(e) {

我有一个在线问卷,我已经链接了一个提交表单,用来将用户的信息和结果发送到我的电子邮件中。很好

现在唯一的问题是,人们可以在不填写个人信息的情况下提交测验结果

如果你能在这方面帮助我,这将是奇妙的,我想,它的人必须完成他们的信息(姓名,电子邮件等)提交结果=)

我真的很感谢你抽出时间

这是我的Js,其中#quesForm是结果,#responseMessage是需要发送的其他信息:

$(function() {
   $('#quesForm').on('submit',function(e) { 
    e.preventDefault();
    var uname = $("input[name=username]").val(); 
    var uemail = $("input[name=email]").val();
        var msg = $("input[name=message]").val()
    $.post('submit.php',{username:uname,email:uemail,message:msg,results:$('#resultKeeper').html(),subject:'Subject of your e-mail'},function(result){
   $('#responseMessage').html(result);
    });
  });
这是我的submit.php

   <?php $name = $_POST['username'];
   $email = $_POST['email'];
   $message = $_POST['message'];
   $results = $_POST['results'];
   $results = strip_tags($results); // add this to remove html tags and all
   $formcontent="From: $name \n Email: $email \n Phone: $message \n Results: \n $results";        
   $recipient = "email@email.com";
   $subject = "subject of email";
   $mailheader = "From: $email \r\n";
   mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
   echo "";
   ?>

提交表单之前,请检查是否有空字段:

$(function() {
   $('#quesForm').on('submit',function(e) { 
    e.preventDefault();
    var uname = $("input[name=username]").val(); 
    var uemail = $("input[name=email]").val();
    var msg = $("input[name=message]").val()

    //check for empty fields
    if(uname==''||uemail==''||msg==''){
    return
    }
    $.post('submit.php',{username:uname,email:uemail,message:msg,results:$('#resultKeeper').html(),subject:'Subject of your e-mail'},function(result){
   $('#responseMessage').html(result);
    });
  });

如果这很重要,也可以在php中执行相同的操作

是。。如何在php中实现这一点?已经感谢您的js=)