我创建了一个适用于Chrome和IE的表单,但不是Firefox。在提交时,它只是转到一个空白屏幕,其中包含我的PHP文件的网址sendContact.php
。
这是标记:
<form action="script/sendContact.php" method="post" class="contactForm">
<div class="textBoxDivs">
<label>Name</label>
<br />
<input type="text" id="name" name="name" size="40" class="textField"/>
</div>
<div class="textBoxDivs">
<label>Phone</label>
<br />
<input type="text" id="phone" name="phone" size="40"class="textField"/>
</div>
<div class="textBoxDivs">
<label>Email</label>
<br />
<input type="text" id="email" name="email" size="40"class="textField"/>
</div>
<div class="textArea">
<label>Please describe what services you will require and your proposed budget.</label>
<br />
<textarea id="message" cols="40" rows="7" name="message" class="textAreaField"> </textarea>
</div>
<div class="formButtonDiv">
<input type="submit" value="submit" class="formBut"/>
<input type="reset" value="reset" class="formBut" />
</div>
</form>
和PHP如下:
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$phone = $_POST['phone'];
$formcontent= "From: $name \n Email: $email \n Phone: $phone \n Message: $message";
$recipient = "al@gmail.com";
$subject = "Contact Form";
$mailheader = "From: $userEmail \r\n";
if (mail($recipient, $subject, $formcontent, $mailheader, $email))
{
header ("Location: thankYou.html");
} else {
echo "mail was not sent";
}
答案 0 :(得分:2)
我现在尝试使用Firefox,而且每件事情都很顺利。顺便说一句,看看你的PHP代码,你应该在发送之前检查表单是否正常。我尝试过空场,我想你只是收到一封来自无人的邮件。
尝试类似:
$name = trim($_POST['name']);
$email = trim($_POST['email']);
$message = trim($_POST['message']);
$phone = trim($_POST['phone']);
$formcontent= "From: $name \n Email: $email \n Phone: $phone \n Message: $message";
$recipient = "alverdeja88@gmail.com";
$subject = "Contact Form";
$mailheader = "From: $userEmail \r\n";
if (!empty($name)
&& !empty($email)
&& !empty($message)
&& mail($recipient, $subject, $formcontent, $mailheader, $email))
{
header ("Location: http://www.dukecitygrafx.com/thankYou.html");
}
else
{
echo "mail was not sent";
}
答案 1 :(得分:1)
删除html文件中的新行(表单标记!)。 Firefox可能有问题要解决这个问题!
在你的sendContact.php中试用die("hello");
所以你可以检查你的脚本是否会被加载
<?php
die("hello");
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$phone = $_POST ['phone'];
$formcontent="From: $name \n Email: $email \n Phone: $phone \n Message: $message";
$recipient = "alverdeja88@gmail.com";
$subject = "Contact Form";
$mailheader = "From: $userEmail \r\n";
if (mail($recipient, $subject, $formcontent, $mailheader, $email)) {
header ("Location: http://www.dukecitygrafx.com/thankYou.html");
die();
} else {
echo "mail was not sent";
}
?>