Defiance Posted July 6, 2009 Share Posted July 6, 2009 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. Link to comment https://forums.phpfreaks.com/topic/164952-solved-php-form-works-in-fx-chrome-safari-does-not-work-in-ie-and-opera/ Share on other sites More sharing options...
haku Posted July 6, 2009 Share Posted July 6, 2009 Show us your HTML - php is run on the browser, so the code on the server is the same regardless of which browser you run it on. But each browser interprets html its own way. Are you using input type image? Link to comment https://forums.phpfreaks.com/topic/164952-solved-php-form-works-in-fx-chrome-safari-does-not-work-in-ie-and-opera/#findComment-869820 Share on other sites More sharing options...
Defiance Posted July 6, 2009 Author Share Posted July 6, 2009 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? Link to comment https://forums.phpfreaks.com/topic/164952-solved-php-form-works-in-fx-chrome-safari-does-not-work-in-ie-and-opera/#findComment-869824 Share on other sites More sharing options...
Defiance Posted July 6, 2009 Author Share Posted July 6, 2009 Ah, seems like it is. Anyway for this to work with an image defined as the submit button? Link to comment https://forums.phpfreaks.com/topic/164952-solved-php-form-works-in-fx-chrome-safari-does-not-work-in-ie-and-opera/#findComment-869839 Share on other sites More sharing options...
PFMaBiSmAd Posted July 6, 2009 Share Posted July 6, 2009 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. Link to comment https://forums.phpfreaks.com/topic/164952-solved-php-form-works-in-fx-chrome-safari-does-not-work-in-ie-and-opera/#findComment-869865 Share on other sites More sharing options...
rhodesa Posted July 6, 2009 Share Posted July 6, 2009 I usually just test for the POST method: if($_SERVER['REQUEST_METHOD'] == 'POST'){ Link to comment https://forums.phpfreaks.com/topic/164952-solved-php-form-works-in-fx-chrome-safari-does-not-work-in-ie-and-opera/#findComment-869870 Share on other sites More sharing options...
Defiance Posted July 6, 2009 Author Share Posted July 6, 2009 Thanks all. Link to comment https://forums.phpfreaks.com/topic/164952-solved-php-form-works-in-fx-chrome-safari-does-not-work-in-ie-and-opera/#findComment-869881 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.