Submit buttons not submitting

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 arrises 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:

  1. <?php
  2. if ($_SERVER['REQUEST_METHOD'] == 'POST')
  3. {
  4.     ...

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.


Related articles

Top | Post a comment | Permalink

User submitted comments

1 Paul wrote

9th August, 2007


Yup, that is actually how I do mine as well. When I need a bit more control over which form has been submitted, in the case of multiple forms on a page, then I will use a unique querystring value.


Penny for your thoughts

Comment posting guide

Your real name will be displayed as the author of the post. Real names are preferred, both first and second names, but nicknames/alter-egos are permitted. Any comments with the author name whose primary aim is to promote their website, and/or company will be removed.

If you supply a website URI then your real name will be clickable to that site. Only one sub-directory is permitted; e.g. http://www.example.org/directory.

Accepted comment input

  • <strong>…</strong>
  • <em>…</em>
  • <blockquote>…</blockquote>
  • <tt>…</tt>
  • <a href="…">…</a>
  • <code>…</code>




Recent articles

Other topics I ramble on about