Jump to content

[SOLVED] PHP form works in Fx, Chrome, Safari. Does not work in IE and Opera.


Defiance

Recommended Posts

Hello,

 

I have a simple contact form parsed and sent to an e-mail address by this:

 

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

$to = "[email protected]";
$subject = "Message from website";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$phone_field = $_POST['phone'];
$message = $_POST['message'];

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

echo "Message successfully sent.";
mail($to, $subject, $body);

} else {

echo "An error has occurred.";

}
?>

 

It works fine in Firefox, Chrome and Safari.

IE and Opera show the error message.

(latest versions of all browsers used)

 

Anyone know what's going on? Thanks.

My apologies, here is the form:

 

<form method="post" action="mailer.php">
   <fieldset>
   Name: <br />
   <input type="text" name="name" size="25" />
   <br />
   E-Mail:
   <br />
   <input type="text" name="email" size="25" />
   <br />
   Phone:
   <br />
   <input type="text" name="phone" size="25" />
   <br />
   Comments:
   <br />
   <textarea rows="6" name="message" cols="50"></textarea>
   <br />
   <input type="image" src="images/submit.png" value="Send" name="submit" />
   </fieldset>
</form>

 

As you can see I am indeed using the image input type, is that the problem?

http://us3.php.net/manual/en/faq.html.php#faq.html.form-image

 

You need to use $_POST['submit_x'] to get this to work in all browsers. You can also use a hidden field with a name and value of your choice and test for the hidden field variable name.

 

IE and Opera are actually just following the w3.org specification. The other browsers are doing their own thing outside of the specification.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.