我看到了另一个与此相关的主题,但仍然有点困惑,因为我仍然是 PHP 的基础。所以我有一个发布到我的 Order.php 的表单。这会发送电子邮件并且工作正常。我希望将表单发布到 Review.php 然后发送。下面是我的 Order.PHP(我从数组中删除了一些输入字段,因为它相当长)。我在考虑 review.php 我可以只使用所有 order.php 代码,但$send = mail($to, $subject, $body, $headers);我可以只在一些 html 中请求$to, $subject, $body, $headers然后有一个 sumbit 按钮将这些发送到 order.php,因为所有数据都将被简化在审核页面中处理。听起来对吗?
order.php如下
<?php 
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
 $to = "packy@mycompany.com";
 $name = $_REQUEST['FitterName'] ; 
 $from = $_REQUEST['FitterEmail'] ; 
 $headers = "From: $from"; 
 $subject = "Online Order"; 
 $name2 = $_REQUEST['CustomerEmail'] ; 
 $grind = join(", ", $_REQUEST["grind"]);
 $woods = join(", ", $_REQUEST["woods"]);
 $hybrids = join(", ", $_REQUEST["hybrids"]);
 $iron = join(", ", $_REQUEST["iron"]);
 $wedges = join(", ", $_REQUEST["wedges"]);
 $fields = array(); 
 $fields{"AccountName"} = "Accounts's Name:  "; 
 $fields{"FitterName"} = "Fitter's Name:  "; 
 $fields{"CustomerCat"} = "__________________________CUSTOMER INFO__________________________"; 
 $fields{"CustomerName"} = "Customer's Name:  ";
 $fields{"CustomerPhone"} = "Customer's Phone:  ";
 $fields{"CustomerAddress"} = "Customer's Address:  ";
 $body = "We have received the following Online Order from www.mycompany.com:\n\n"; foreach($fields as $a => $b){   $body .= sprintf("%2s %s\n",$b,$_REQUEST[$a]); }
 $body2 = "Please Review the following Online Order from www.mycompany.com:\n\n"; foreach($fields as $a => $b){     $body2 .= sprintf("%2s %s\n",$b,$_REQUEST[$a]); }
 $headers2 = "From: noreply@mycompany.com"; 
 $subject2 = "Thank you for your order"; 
 $autoreply = "Thank you for your order. Customer service will call in the next 24 hours to review your order.";
 $autoreply2 = "Company Customer";
 if($from == '') {print "You have not entered an email, please go back and try again";} 
 else { 
 if($name == '') {print "You have not entered a name, please go back and try again";} 
 else { 
 $send = mail($to, $subject, $body, $headers); 
 $send2 = mail($from, $subject2, $autoreply, $headers2); 
 $send3 = mail($name2, $subject2, $autoreply2, $headers2); 
 if($send) 
 {header( "Location: http://fitter.henry-griffitts.com/fitter/success.php" );} 
 else 
 {print "We encountered an error sending your mail, please review your information"; } 
 }
}
 ?>