Menu

Submit buttons not submitting

This is an old post from 2007. As such, it might not be relevant anymore.

Wow, I have been busy lately, what with a hectic workplace and personal life. But I am here to tell you about a little problem I have known about for years but recently popped up when a friend couldn’t work out what was happening.

The problem essentially arises with bad programming practices, checking to see if the submit button is set (isset()) before allowing the form to be processed. If you press the ‘Enter’ key whilst in one of the inputs then Internet Explorer does, and will not, send the submit button along with the HTTP header request. Strange, huh?

I haven’t quite worked out why they would do this, I can only assume it is a bug on their behalf from their legacy spaghetty code.

So, how can I avoid this?

Quite simply really. Checking to see if the form button exists is, essentially, a bad programming practice in my opinion—after all, the submit button does not (or rather, should not) contain any information essential to the forms processing. This is how I would, and do, check that a form has been submitted:

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
...
...
}

That’s it. Of course, this only works for POST requests since GET requests are every other type of request (See my other note POST requests are actually GETs), but GET’s should contain some kind of action keyword anyways.