...

View Full Version : Contact form not working in IE but fine in Firefox... Help!



claireym
01-22-2010, 03:06 PM
Hi everyone,

I'm having a problem that is pulling my hair out. I have made a contact form that works perfect in Firefox, it sends the email and directs the user to the thankyou page which is "contactthanks.html", but it will not do either in IE. It won't even send the mail and it just comes up "blarg!".

Can anyone help me? I've looked at so many tutorials to find out what the problem is but can't seem to sort it out... I'm not a PHP expert but I'm thinking there's probably something minor that IE doesn't like and I just cant figure it out, any ideas? Here's my code:

HTML:

<form method="POST" action="mailer.php" class="cssform3">
<p><label>Your Name:</label><input type="text" name="name" /></p>
<p><label>Your Email:</label><input type="text" name="email" /></p>
<p><label>Your Message:</label><textarea name="message"></textarea></p>
<input type="image" value="Submit" name="submit" class="submitbtn" src="images/submit.gif" >
</form>

PHP

<?php
if(isset($_POST['submit'])) {

$to = "myemail@gmail.com";
$subject = "Contact Form";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];

$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

mail($to, $subject, $body);
Header("Location: contactthanks.html");
} else {

echo "blarg!";

}
?>

Thanks in advance for any help or ideas on whats up with this! As I said, FF is fine, just IE seems to not like it... Thanks!

angst
01-22-2010, 03:13 PM
what version of IE?

try changing the submit button like:



<input type="submit" value="Submit" name="submit" />


try that and see if it works in IE, I'm not sure that IE sees an input type image as a submit button.

claireym
01-22-2010, 03:20 PM
Hey there,

Thankyou so so much, it works!! :) You were right, that's all that was wrong! Thanks so much! :)

JAY6390
01-22-2010, 03:35 PM
Wow didn't know that IE didn't support the image input. That must not be true for the latest versions. Is the version IE6

abduraooft
01-22-2010, 03:40 PM
what version of IE?

try changing the submit button like:



<input type="submit" value="Submit" name="submit" />


try that and see if it works in IE, I'm not sure that IE sees an input type image as a submit button.


Hey there,

Thankyou so so much, it works!! :) You were right, that's all that was wrong! Thanks so much! :)
Ah wait! An input having type="image" can submit a form, just like the one having type="submit"

The problem lies in the isset() part. The image input submits the x and y coordinates of the user click. Thus you need to check for the submit_x or submit_y variables in the $_POST array, read http://php.net/manual/en/language.variables.external.php#language.variables.external.form.submit

JAY6390
01-22-2010, 03:41 PM
Ah that sounds more like it :)

claireym
01-22-2010, 03:57 PM
The version was IE8 although it would not work in IE7 either but it's all working now! Thanks guys! :)

abduraooft
01-22-2010, 04:09 PM
The version was IE8 although it would not work in IE7 either but it's all working now! Thanks guys! :)Did you see my post above (http://www.codingforums.com/showpost.php?p=913795&postcount=5)?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum