Php邮件从上一页提取表单数据
我在一个php上填写了一张表格,如下所示:Php邮件从上一页提取表单数据,php,html,css,email,Php,Html,Css,Email,我在一个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> <in
<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 = $_REQUEST['first_name'];
$last_name = $_REQUEST['last_name'];
它将从cookie、post或get中发送的请求中获取数据。使用此选项
....'+$variables+'...
因为使用时无法从所需的变量中获取值,请使用调用变量
比如说
<?php
$t = 'test';
echo "$t"; // will result test
echo '$t'; // will result $t
?>
错误背后的原因是标记不正确。应该是:
<form action="students_conf.php" method="post" id="contactform">
此外,他们没有做好自己的工作。当嵌入php时,这难道不是这样吗?您的表单中是否有操作和方法?字体大小:16.8px?哇,太准确了。您没有向初学者显示标记更改。这是表单标记:它与问题无关。问题没有提供足够的信息,例如Tag,但是,如果他使用提交数据,那么我们可以使用给定的行获取数据。正确,但获取变量的范围应尽可能精确,以避免变量之间可能的冲突,例如$\u GET['first\u name'!=$_POST['first_name']