0

我创建了一个适用于 Chrome 和 IE 的表单,但不适用于 Firefox。提交时,它只是进入一个空白屏幕,其中包含我的 PHP 文件的 URL 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";
}
4

2 回答 2

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";
}
于 2012-08-15T10:14:46.713 回答
1
  1. 删除 html 文件中的新行(表单标记!)。Firefox 可能会遇到问题来解决这个问题!

  2. die("hello");在您的 sendContact.php 中尝试

所以你可以检查你的脚本是否会被加载

<?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";
}
?>
于 2012-08-15T10:10:04.250 回答