PHP Mailer';t发送所有字段


PHP Mailer Doesn't Send All Fields

我是PHP新手,我正在尝试创建一个PHP表单字段,我有四个名为Output1、Output2、Output3和Output4的"复选框",但当我选择所有四个复选框时,它只向我发送一个值,而不是全部四个值。

注意我还有其他来自的字段,但我只是想为您提供Output的HTML表单信息。

这是HTML:

 <form id="surveyForm" class="form" action="mailsurvey.php" method="post" name="surveyForm" enctype="multipart/form-data" onsubmit="return ValidateContactForm2();">
 <input id="Output1" type="checkbox" name="Output1" value="Isolated" />
 <input id="Output2" type="checkbox" name="Output2" value="Isolated" />
 <input id="Output3" type="checkbox" name="Output3" value="Isolated" />
 <input id="Output4" type="checkbox" name="Output4" value="Isolated" />
 </form>

PHP代码:

 <?php 
 require("includes/class.phpmailer.php");
 require("includes/class.smtp.php");
 require("includes/class.pop3.php");
 if($_FILES['headshot']['name']!="")
 {
 $imgtype=explode('.',$_FILES['headshot']['name']);
 $len=sizeof($imgtype);
 $image_file=uniqid().'.'.$imgtype[$len-1];
 $tmppath='uploads/';
 move_uploaded_file($_FILES['headshot']['tmp_name'],$tmppath.$image_file);
 $file_path=$tmppath.$image_file;
 }
 else
 {                
      $file_path="";
 }
 if($_FILES['bodyshot']['name']!="")
 {
      $imgtype=explode('.',$_FILES['bodyshot']['name']);
      $len=sizeof($imgtype);
      $image_file=uniqid().'.'.$imgtype[$len-1];
      $tmppath='uploads2/';
      move_uploaded_file($_FILES['bodyshot']['tmp_name'],$tmppath.$image_file);
      $file_path2=$tmppath.$image_file;
 }
 else
 {                
      $file_path2="";
 }

 $mail = new PHPMailer();
 $mail->Host = "localhost";
 $mail->Mailer = "smtp";
 $name = $_POST['name'];
 $company = $_POST['company'];
 $email = $_POST['email'];
 $phone = $_POST['phone'];
 $comments = $_POST['Comments'];
 $totalpower = $_POST['Total_Power']." ".$_POST['Total_Power2']."           ".$_POST['Total_Power3']." ".$_POST['Total_Power4']." ".$_POST['Total_Power5'];
 $input = $_POST['Input']." ".$_POST['Input2']." ".$_POST['Input3']."      ".$_POST['Input4'];
 $strings = $_POST['Strings4']." ".$_POST['Strings3']." ".$_POST['Strings2']."      ".$_POST['Strings']; 
 $output = $_POST['Output1']." ".$_POST['Output2']." ".$_POST['Output3']."      ".$_POST['Output4'];
 $dimming = $_POST['Dimming4']." ".$_POST['Dimming3']." ".$_POST['Dimming2']."      ".$_POST['Dimming'];
 $packaging = $_POST['Packaging4']." ".$_POST['Packaging3']." ".$_POST['Packaging2']."      ".$_POST['Packaging'];
 $subject = "New Product Inquiry / Survey";
 $body = "Name: " .$name. "<br> ".
 "Company: " .$company. "<br>".
 "Phone: " .$phone."<br>".
 "Email: " .$email."<br><br><hr>".
 "Total Power: " .$totalpower."<br>".
 "Input: " .$input."<br>".
 "Strings: " .$strings."<br>".
 "Output: " .$output."<br>".
 "Dimming: " .$dimming."<br>".
 "Packaging: " .$packaging."<br>".
 "Comments: " .$comments."<br>"
 ;
 $mail->IsSMTP();
 $mail->From = 'support@domain.com';
 $mail->FromName = 'support@domain.com';
 $mail->Subject = "New Product Inquiry";
 $mail->AltBody = "To view the message, please use an HTML compatible email viewer!";                // optional, comment out and test
 if($file_path!="")
 {
 $mail->AddAttachment($file_path);
 }
 if($file_path2!="")
 {
      $mail->AddAttachment($file_path2);
 }
 $mail->MsgHTML($body);
 $mail->AddAddress('email@domain.com');
 if(!$mail->Send())
 {
      $msg = "Unable to send email";
 }
 else
 {
      $msg = header("location: thank-you2.php");
 }
 ?>

有人能告诉我,如果用户选择了所有四个框,为什么此表单不会发送ALL输出字段吗。如果你有任何问题,请告诉我。

谢谢,

Frank

我弄清楚了我的问题是什么,以及我想发布这个答案让其他人知道的原因。

我的问题是我使用了错误的PHP文件。我的站点中有两个相同的PHP文件,一个埋在几个文件夹下,另一个在站点的根目录下。那个burred是我本应该修改的,因为那是LIVE文件。当我上传一个文件时,因为它是错误的,所以不起作用。我通过仔细检查表单页面表单元素中的路径来了解这一点。

<form id="surveyForm" class="form" **action="subfolder/formmailer_scripts/mailsurvey.php"** method="post" name="surveyForm" enctype="multipart/form-data" onsubmit="return ValidateContactForm2();">

因此,故事的重点是要注意,确保你不会过度关注简单的事情。我浪费了大约一个小时重新加载了一个不需要的文件。希望这能帮助其他人!