2015-11-11 42 views
-3

我希望表單輸入中的'姓名'(http://besthomebuildercoloradosprings.com/)顯示在自動回覆電子郵件中(在「祝賀」字詞後面)。儘管插入<?php echo $name; ?>,但它目前不顯示在我的html中。我已經看過所有的論壇和實驗,但沒有任何作品。添加PHP以形成電子郵件回覆

以下是內容我webformmailer.php文件:

  <?php 
     $name = $_POST['name']; 
     $email = $_POST['email']; 
     $phone = $_POST['phone']; 
     $bonus = $_POST['bonus']; 
     $formcontent=" Hello, \n \nThis email has been sent to you from the Challenger Homes BestHomeBuilderColoradoSprings.com contact form. \n \n From: $name \n Phone: $phone \n Email: $email \n Bonus: $bonus \n"; 
     $recipient = "[email protected]"; 
     $subject = "New lead from Challenger Homes!"; 
     $mailheader = "From: [email protected] \r\n"; 
     mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); 
     header("Location: http://www.besthomebuildercoloradosprings.com/thankyou.html"); 
     $headers = 'MIME-Version: 1.0' . "\r\n"; 
     $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

     @mail($email, $email_subject, $replymsg, $headers); 


     $replymsg = " 
     <html> 
     <head> 
     <title>Your Challenger Certificate</title> 
     </head> 
     <body> 


     <table style='cell-padding:0px; cell-spacing:0px; border-collapse:collapse; border:0px; border-spacing:0px; padding:0px; margin: 0 auto;'> 

     <tr> 
     <td style='border:0px; padding:0px;'> 
     <img src='http://www.besthomebuildercoloradosprings.com/images/cert1.jpg'> 
     </td> 
     <td style='border:0px; padding:0px;'> 
     <img src='http://www.besthomebuildercoloradosprings.com/images/cert2.jpg'> 
     </td> 
     <td style='border:0px; padding:0px;'> 
     <img src='http://www.besthomebuildercoloradosprings.com/images/cert3.jpg'> 
     </td> 
     </tr> 

     <tr> 
     <td style='border:0px; padding:0px;'> 
     <img src='http://www.besthomebuildercoloradosprings.com/images/cert4.jpg'> 
     </td> 
     <td width='434px' style='background-color:#f4f4f2; border:0px; padding:0px;'> 
     <strong>Congratulations <?php echo $name; ?> ! </strong> 
     <br><br> 
     Thank you for registering with Challenger Homes. You are eligible for incredible and exclusive internet savings. Present this certificate at any Challenger Model Home to get started! Or call today to schedule an appointment: 719-602-5824. 
     <br><br> 
     We are here to serve you and help make life better for you in a brand-new Challenger Home! 
     </td> 
     <td style='border:0px; padding:0px;'> 
     <img src='http://www.besthomebuildercoloradosprings.com/images/cert6.jpg' style='display:block;'> 
     </td> 
     </tr> 

     <tr> 
     <td style='border:0px; padding:0px;'> 
     <img src='http://www.besthomebuildercoloradosprings.com/images/cert7.jpg' style='display:block;'> 
     </td> 
     <td style='border:0px; padding:0px;'> 
     <img src='http://www.besthomebuildercoloradosprings.com/images/cert8.jpg' style='display:block;'> 
     </td> 
     <td style='border:0px; padding:0px;'> 
     <img src='http://www.besthomebuildercoloradosprings.com/images/cert9.jpg' style='display:block;'> 
     </td> 
     </tr> 

     </table> 




     </body> 
     </html> 
     " 

     ; 
     $email_subject = "Your Special Internet Savings from Challenger Homes"; 

     mail($email, $email_subject, $replymsg, $headers); 

     ?> 

回答

0

您的情況<?php echo $name; ?>正在PHP中使用PHP。這是沒有意義的:

<?php 
$name = "test"; 
$replymsg = "<?php echo $name; ?>"; 

不如干脆{$name}使用:

<?php 
$name = "test"; 
$replymsg = "Blah blah {$name} and more."; 

或者使用string concatenation

<?php 
$name = "test"; 
$replymsg = "Blah blah " . $name . " and more."; 
+0

完美的作品。 4個小時的掙扎,2分鐘內修復。謝謝NoChecksum和Cottrell。 – Mustang

0

該標記是一個PHP文字字符串,它是在雙引號,所以你並不需要一個標籤都沒有。自動插入雙引號字符串中的變量。只需將<?php echo $name; ?>替換爲$name,您就會很好。