我正在尝试为房地产网站建立联系表单,并且提交工作正常。但是当它到达我的电子邮件地址时,出于某种原因,“租户”和“房东”字段都是空的。我错过了什么吗?参见:
<?php
$action=$_REQUEST['action'];
if ($action=="") /* display the contact form */
{
?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
First & Last Name:<br>
<input name="name" type="text" value="" size="30"/><br> <br>
Your Email Address:<br>
<input name="email" type="text" value="" size="30"/><br> <br>
Tenants, please describe what you're looking for:<br>
<textarea name="tenants" rows="7" cols="30"></textarea><br> <br>
Landlords, please describe what you're looking for:<br>
<textarea name="landlords" rows="7" cols="30"></textarea><br> <br>
Additional Comments:<br />
<textarea name="message"></textarea>
<br>
<center>
<input type="submit" value="Send email"/> </center>
<br /></p>
</form>
<?php
}
else /* send the submitted data */
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$tenants=$_REQUEST['tenants'];
$landlords=$_REQUEST['landlords'];
$message=$_REQUEST['message'];
if (($name=="")||($email=="")||($message==""))
{
echo "All fields are required, please fill <a href=\"\">the form</a> again.";
}
else{
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Leasing Submission";
mail("myemailhere@test.com", $subject, $message, $from);
echo "Email sent!";
}
}
?>
答案 0 :(得分:0)
您实际上并未发送房东或租户数据。您正在使用这些字段并将它们分配给变量,但是您没有将它们附加到$ message变量,这是通过电子邮件发送的。
尝试类似:
$tenants = $_REQUEST['tenants'];
$landlords = $_REQUEST['landlords'];
$message = $_REQUEST['message'];
$message .= "\n\nLandlords: $landlords\n\nTenants: $tenants";
答案 1 :(得分:0)
试试这个:
else /* send the submitted data */
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$tenants=$_REQUEST['tenants'];
$landlords=$_REQUEST['landlords'];
$message=$_REQUEST['message'];
$fullmessage = " {$name}, mailaddres {$email},tenant info: {$tenants} , landlord info: {$landlords}. He gaves us the following message: {$message}";
if (($name=="")||($email=="")||($message==""))
{
echo "All fields are required, please fill <a href=\"\">the form</a> again.";
}
else{
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Leasing Submission";
mail("myemailhere@test.com", $subject, $fullmessage, $from);
echo "Email sent!";
}
}
?>