添加PHP以形成电子邮件响应

时间:2015-11-11 23:28:42

标签: php forms message

我想要这个名字&#39;从表单输入(http://besthomebuildercoloradosprings.com/)显示在自动回复电子邮件中(在#39;祝贺后#39;之后)。尽管插入了<?php echo $name; ?>,它目前还没有在我的html中显示。我遍布论坛并进行了实验,但没有任何效果。

以下是我的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 = "sally@superfinedesigns.com";
      $subject = "New lead from Challenger Homes!";
      $mailheader = "From: sally@superfinedesigns.com \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);

      ?>

2 个答案:

答案 0 :(得分:0)

该标记位于双引号的PHP文字字符串中,因此您根本不需要标记。自动插入双引号字符串中的变量。只需将<?php echo $name; ?>替换为$name,您就会很好。

答案 1 :(得分: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.";