我创建了一个适用于 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";
}