我在为我的网站创建的联系表单时遇到问题 . 我不是PHP专家,但我认为一个合适的联系表单比一个简单的href mailto链接更专业 . 我设法收到了电子邮件,它告诉我发件人,但没有主题,只是没有文字的空白 . 此外,我每天都会收到来自没有发件人的2封电子邮件
这就是我在PHP中在名为contact.php的页面中所做的 . 我希望你能提供帮助:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$form1_services = $_POST['form1_services'];
$msg = $_POST['msg'];
$formcontent="From: $name \n Message: $message";
$recipient = "dandrea.alessandro81@gmail.com";
$subject = "Customer Inquiry";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You! Keep in touch soon!" . " -" . "<a href='index.html' style='text-decoration:none;font-family: 'gooddogregular';color:#009999;'> Return Home</a>";
?>
这是HTML中的实际形式:
<form action="contact.php" method="post">
<fieldset>
<legend></legend>
<div class="controlgroup">
<label for="form1_name">Name *</label>
<input type="text" placeholder="Enter your full name*" name="name" value>
</div>
<div class="controlgroup">
<label for="form1_email">Email *</label>
<input type="text" placeholder="Enter a valid email address*" name="email" value>
</div>
<div class="controlgroup">
<label for="form1_services">Services Required</label>
<select id="form1_services" name="services">
<option value="Website Design"> Website Design (from scratch) </option>
<option value="Resposive Design"> Responsive Design </option>
<option value="Customize a Site"> Customize a Site </option>
<option value="Quotation"> Quotation </option>
</select>
</div>
<div class="controlgroup">
<label>Project Info*</label>
<textarea placeholder="Ciao Alessandro, I am contacting you because...*" id="msg" name="msg" required aria-required="true"></textarea>
</div>
<input type="submit" name="submit_btn" id="send" value="Hit me up!" class="wow rubberBand animated" data-wow-delay="2s">
</fieldset>
</form>
非常感谢提前 . 亚历山德罗
2 回答
看看你的PHP,你收集了很多字段,然后实际上并没有使用它们 . 试试这个:
请记住,此时,您实际上并未验证任何此类信息,因此您无法确定电子邮件地址或名称是否真的有效,但这至少应该告诉您要发布的内容 .
尝试添加一些 Headers :