【发布时间】:2014-07-27 12:13:43
【问题描述】:
所以我在一个 php 上填写了一个表格,如下所示:
<p>
<label for="first_name">First Name: </label>
<input type="text" size="30" name="first_name" id="first_name"/>
</p>
<p>
<label for="last_name"> Last Name:</label>
<input type="text" size="30" name="last_name" id="last_name"/>
</p>
<p>
<label for="address_street">Street:</label>
<input type="text" size="30" name="address_street" id="address_street"/>
</p>
<p>
<label for="address_city">City:</label>
<input type="text" size="30" name="address_city" id="address_city"/>
</p>
<p>
<label for="address_state">State/Province:</label>
<input type="text" size="30" name="address_state" id="address_state"/>
</p>
<p>
<label for="email">Your e-mail: </label>
<input type="text" size="30" name="email" id="email"/>
</p>
<p>
<label for="phone">Your phone number: </label>
<input type="text" size="30" name="phone" id="phone"/>
</p>
这是在一个 php 页面上。从这里,它转到另一个 php,其中一部分包含向收件人发送 html 电子邮件的脚本。
问题是,即使我认为我正确地声明了变量并将它们正确地混合到 html 中,我似乎也无法让它提取变量。
<?php
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$to = "devtech8@gmail.com, example@gmail.com";
$subject = "HTML email for ALPS";
$message .= '
<html>
<body>
<div style="display: inline-block; width: 28%; float: left;">
<img src="http://englishintheusa.com/images/alps-logo.jpg" alt="ALPS Language School" />
</div>
<div style="display: inline-block; width: 68%; float: right;">
<p style="color: #4F81BD; font-size: 20px; text-decoration: underline;">Thanks You For Your Inquiry!</p>
</div>
<div style="padding-left: 20px; color: #666666; font-size: 16.8px; clear: both;">
<p>Dear $first_name $last_name ,</p>
</br >
<p>Thank you for the following inquiry:</p>
</br >
</br >
</br >
</br >
<p>****Comment goes here****</p>
</br >
</br >
<p>We will contact you within 2 business days. Our office is open Monday-Friday, 8:30 AM - 5:00 PM Pacific Standard Time.</p>
</br >
<p>Thank you for your interest!</p>
</br >
</br >
<p>Best Regards,</p>
</br >
</br >
<p>ALPS Language School</p>
</br >
</br >
<p>430 Broadway East</p>
<p>Seattle WA 98102</p>
<p>Phone: 206.720.6363</p>
<p>Fax: 206. 720.1806</p>
<p>Email: info@englishintheusa.com</p>
</div>
</body>
</html>';
// Always set content-type when sending HTML email
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
mail($to,$subject,$message,$headers);
?>
所以你知道我想从哪里得到first_name 和last_name。好吧,它没有正确输出。
有人可以帮忙吗?
【问题讨论】:
-
此外, 没有做好他们的工作。嵌入php时不能这样吗?
-
你的表单中有动作和方法吗?
-
font-size: 16.8px;?哇,太准确了。你没有显示你的<form>标签 -
首先将
</br >更改为<br />。 -
这里是表单标签: