嘿伙计我使用以下脚本作为电子邮件联系表单,当我测试表单时,它不包括我在收到的电子邮件中添加到表单(电话和公司)的2个附加字段
非常新的PHP。谁能帮我吗?干杯!
<?php
$action=$_REQUEST['action'];
if ($action=="") /* display the contact form */
{
?> <div class="input-group">
<form action="#contact" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit" >
<input name="name" type="text" placeholder="Your Name" class="form-control form-control1" />
<input name="email" type="text" placeholder="Email" class="form-control form-control1" />
<input name="phone" type="text" placeholder="Phone" class="form-control form-control1" />
<input name="company" type="text" placeholder="Company" class="form-control form-control1" />
<input name="subject" type="text" placeholder="Subject" class="form-control form-control1"/>
<textarea name="message" class="form-control" rows="12" placeholder="Let us know what you require"></textarea><br>
<input type="submit" value="Send Message" class="quoteb" />
</form>
</div>
<?php
}
else /* send the submitted data */
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['phone'];
$message=$_REQUEST['company'];
$message=$_REQUEST['message'];
$message=$_REQUEST['subject'];
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="$subject";
mail("sales@webxury.com", $subject, $message, $from);
echo "Email sent, we will contact you ASAP, thank you";
}
}
?>
答案 0 :(得分:6)
您每次都在重新定义$message
。尝试:
$message = $_REQUEST['phone'];
$message .= $_REQUEST['company'];
$message .= $_REQUEST['message'];
$subject = $_REQUEST['subject'];
最后一个应该是$subject
。
答案 1 :(得分:1)
每次重新分配变量$ message。 而不是这个你可以使用以下语法:
$message =$_REQUEST['phone'];
$message .=$_REQUEST['company'];
$message .=$_REQUEST['message'];
$message .=$_REQUEST['subject'];
答案 2 :(得分:1)
对于换行符,请尝试以下
$message = $_REQUEST['phone'];
$message .="\n";
$message .= $_REQUEST['company'];
$message .="\n";
$message .= $_REQUEST['message'];
由于我是新用户,我无权为新行查询添加评论,因此请在此处添加。
答案 3 :(得分:0)
我认为缺少的数据是&#39;手机&#39;,&#39;国家&#39;和&#39;消息&#39;。您要将每个作业替换为$message
。您需要查看string concatenation。