在PHP上这么糟糕,我决定在这里作为最后的手段发布。 我想在通过PHP联系表单发送的电子邮件的邮件正文中添加“who”变量。该表单适用于姓名,电子邮件和消息,但“谁”输入我希望成为电子邮件消息的一部分,作为一种沟通方式。
我试图添加$ who = $ _ REQUEST ['who'];以及$ who到邮件行,但都没有工作,后者甚至根本不发送电子邮件。
<?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">
<input name="name" type="text" placeholder="Your Name" value="" size="14"/>
<input name="email" type="text" placeholder="Your Email" value="" size="14"/>
<textarea name="who" placeholder="Who should we contact?" rows="1" cols="14"></textarea>
<textarea name="message" placeholder="Description" rows="2" cols="14"></textarea><br>
<input type="submit" class="button special" value="SUBMIT"/>
</form>
<?php
}
else
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
if (($name=="")||($email=="")||($message==""))
{
echo "All fields are required, please fill out <a href=\"\">the form</a> again.";
}
else{
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Referral for ******* **";
mail("chris@********.com.au", $subject, $message, $from);
}
{
echo "<script type='text/javascript'>window.location.href ='../thanks.php';</script>";
}
}
?>
答案 0 :(得分:0)
在PHP中。是连接运算符,它返回其左右参数的串联 试试这个
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$message = $_REQUEST['message'] . "\n\rFrom: " . $_REQUEST['who'];