我正在嘗試爲一個房地產網站建立一個聯繫表單,並且提交工作。但是,當它到達我的電子郵件地址時,出於某種原因,「租戶」和「業主」字段爲空。我錯過了什麼嗎?請參閱:PHP提交表單不發送所有字段?
<?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("[email protected]", $subject, $message, $from);
echo "Email sent!";
}
}
?>
你不包括你的'郵件()' –
在體內POST數據他們不爲空 - 你永遠不會把它們放在首位。 –
另外,請考慮使用[適當的** header()**信息](http://php.net/manual/en/function.mail.php) –