PHP IE Form Problem

PHP/IE Form Problem, Tutorial and Solution


Problem Summary: I could not get Internet Explorer to submit/post my HTML form that was handled by a PHP script. The form worked fine in Firefox, Opera, Netscape, Safari and other browsers.

Example: For a long time I could not get even a simple user login page to work,
when the user entered their user name and password, then pressed submit, IE would just return them to the same screen.
The user could login successfully in other browsers. This actually had me looking in the wrong direction for a long time, initially thinking this was caused by a bug involving PHP and IE's handling of sessions.

Surprise Solution: I had tried every solution, suggested or imagined - to no avail. I changed header information, session and cookie code, mysql database and query tweaks, icon requests and many more suggested on php.net and PHP forums.

When working with PHP and IE, the answer is....

Use the default form button for the submit button, NOT an image-based, "custom" button. Below are two identical pieces of code - apart from ONE line of code which differenciates the two different submit buttons. Sure enough, one works, and one doesn't!

This code uses an image-button, try submitting the form using Internet Explorer and then with Firefox.

Username:
Password:

<html> <head></head> <body bgcolor="#000000"> <form name="mainForm" action="ie_problem.php" name="login" method="post"> <table bgcolor="#eeeeee" width="" cellpadding="1" cellspacing="1"> <tr> <td align="right">Username:</td> <td><input type="text" name="username" size="10"></td> </tr> <tr> <td align="right">Password:</td> <td><input type="password" name="password" size="10"></td> </tr> <tr> <td align="center" colspan="2"> <INPUT TYPE="image" src="button-submit.gif" NAME="submit"> </td> </tr> </table> </form> </body> </html>
This code uses a regular form button, try submitting the form using Internet Explorer and then with Firefox.

Username:
Password:

<html> <head></head> <body bgcolor="#000000"> <form name="mainForm" action="ie_problem.php" name="login" method="post"> <table bgcolor="#eeeeee" width="" cellpadding="1" cellspacing="1"> <tr> <td align="right">Username:</td> <td><input type="text" name="username" size="10"></td> </tr> <tr> <td align="right">Password:</td> <td><input type="password" name="password" size="10"></td> </tr> <tr> <td align="center" colspan="2"> <INPUT TYPE="submit" NAME="submit"> </td> </tr> </table> </form> </body> </html>

I hope this explanation saves others the wasted (and almost silly) countless research hours that I had to invest in order to learn this solution.

LOOKING FOR AN AFFORDABLE, RELIABLE PHP HOST? We recommend 1&1.
Banner

© Michael Devin 2006