Reputation: 23
I created a form which works in Chrome and IE, but not Firefox. On submit, it simply goes to a blank screen with the URL of my PHP file, sendContact.php
.
Here's the markup:
<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>
and the PHP is as follows:
$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 = "[email protected]";
$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";
}
Upvotes: 0
Views: 1078
Reputation: 66
Remove the new Line in your html file (form Tag!). Firefox could have problems to solve this!
Try a die("hello");
in your sendContact.php
So you can check whether your script will be loaded
<?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 = "[email protected]";
$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";
}
?>
Upvotes: 1
Reputation: 139
I've tried on Firefox right now, and every thing went fine. By the way, looking at your php code, you should check if the form is ok before sending it. I've tried with empty field and I guess you just receive a mail from nobody..
Try something like:
$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 = "[email protected]";
$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";
}
Upvotes: 2