php email将字段组合在一起发送电子邮件

时间:2017-08-17 10:18:12

标签: php email

尝试组合将字段拖放到正文中,此处发送的电子邮件是我的代码。只返回1下拉。想要将消息和消息1从下拉列表组合到$ comment字段在线尝试多个解决方案但似乎无法找到有效的解决方案。请帮忙

  $admin_email = "CrazyCatLadyBrewing@baunochs.com";
  $email = $_REQUEST['email'];
  $subject = "Beverage Request";
  $comment = $_REQUEST['message']);


  //send email
  mail($admin_email, "$subject", $comment, "From:" . $email);

  //Email response
  echo "Thank you for contacting us!";
  }

  //if "email" variable is not filled out, display the form
  else  {
?>

<form method= "post" action= "<?php echo $_SERVER [ 'PHP_SELF' ] ;?>" />
  <table>
    <tr>
        <td>Email: <input name="email" type="text" /><br />
        </td>
    </tr>
    <tr>
      <td>Beverage Choice </td>
        <td><select id="message1" Name="message1">
                <option value="Beer">Beer</option>
                <option value="Wine">Wine</option>
                <option value="Cidar">Cidar</option>
            </select>
        </td>

        <td>Size of bottle </td>
        <td><select id="message" Name="message">
                <option value="Sample">Sample</option>
                <option value="12 oz">12 oz</option>
                <option value="22 oz">22 oz</option>
                <option value="32 oz">32 oz</option>
            </select>
        </td>


    </tr>
    <tr>

1 个答案:

答案 0 :(得分:0)

$admin_email = "CrazyCatLadyBrewing@baunochs.com";

$email = $_REQUEST['email'];

$subject = "Beverage Request";

$comment = $_REQUEST['message']." ".$_REQUEST['message1']; 

您需要将message和message1值连接起来存储在$ comment变量中。