Strange form submit behavior in IE

This is a discussion on "Strange form submit behavior in IE" within the PHP Forum section. This forum, and the thread "Strange form submit behavior in IE are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Apr 26th, 2007, 19:46
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Strange form submit behavior in IE

I have a form in one php page (addcomment.php) that submits to another (antibot.php) The code is below:
Code: Select all
<h2>User Login</h2>
<div class="loginwrap"><div class="badrobot">
<img src="img/badrobot.jpg" width="190" height="358" alt="BAD ROBOT!"></div>
<div class="loginexplan"><p>You have to log in before your message will be posted. But 
<strong>don't worry</strong> - this is <em>very</em> easy, and will only take you a minute. 
Best of all, you should only have to do this once. After that, this website should recognize 
you and you'll be allowed to post comments on all DHS57 interactive pages without logging in again.</p>
<p>This minor security measure is made necessary by 'bad robots' all over the internet. 
Without this, the interactive pages of DHS57.com (like the one that brought you here) would 
be filled with nasty, vulgar things that no one really wants to see. (Or maybe you do, but not 
here you won't!) If you want to know more about internet 'robots', you can 
<a href="antibot.php">click here</a>.</p>
<p><strong>Note:</strong> If you're seeing this page every time, please 
<a href="contact.php?msgid=57119">ask the webmaster for assistance</a>.</p>
</div>
<div class="clearing"></div>
</div>
    <h4>Steps for logging in:</h4>
    <ol><li>Enter the first three or four letters of your last (or maiden) name in the box below. 
    (You may enter in your entire last/maiden name if you like.)</li>
    <li>Click the &ldquo;Look Me Up&rdquo; button</li>
    <li>Follow the simple instructions on the next page.</li>
    <div class="namelookup">
        <form action="antibot.php" method="post">    
        <input type='hidden' name='return2' value='<? echo $return2; ?>'>
        <input type='hidden' name='eventid' value='<? echo $eventid; ?>'>
        <input type='hidden' name='postmsg' value='<? echo $postmsg; ?>'>
        <br><label for="cmname">Last name</label><br>
            <input type="text" name="cmname" size="20" maxsize="20"> 
            <input class="lookupbutton" type="submit" name="lookmeup" value="Look Me Up">
        </form>
    </div>
If $_POST['lookmeup'] isn't set in antibot.php, it displays an informational page about bots, comment spam, etc.

Here's where the weirdness comes in...

In FF, I can type a name into the cmname input and hit enter - and FF behaves as it should. But in IE, I have to actually click the "lookmeup" (submit) button. If I don't - if I just hit the enter key, antibot.php behaves as though $_POST['lookmeup'] isn't set.

Has anyone ever encountered anything similar? Is there any kind of workaround? Thanks in advance!
Reply With Quote

  #2 (permalink)  
Old Apr 26th, 2007, 22:18
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: Strange form submit behavior in IE

That's because the value of a button is only actually submitted when you click on it.
it seems that when you press enter, FF will simulate a click on the submit control.
IE however is submitting the form, without simulating this click, therefore the value of the submit button isn't sent with the form.

on your form and field elements, add a bit of code onkeypress that checks for the 'enter' key. When it's pressed, simulate a click on the submot button - button.click()
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
  #3 (permalink)  
Old Apr 27th, 2007, 02:34
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: Strange form submit behavior in IE

Interesting. So, armed with that knowledge, (I didn't want to use javascript, so) I added a hidden input with name="postid" and value="addcomment". Then, in the handler page, I changed
Code: Select all
if (isset($_POST['lookmeup'])) {
to
Code: Select all
if ($_POST['postid'] == "addcomment") {
Works like a charm. Thanks for the lesson, Diego!
Reply With Quote
  #4 (permalink)  
Old Apr 27th, 2007, 19:36
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: Strange form submit behavior in IE

Well I could have told you to do that before...
You said something about 'bots' and I thought you needed the click event to filter out spam bots (they don't click).
Now that I've read your post properly, I'm glad the info helped.
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
Reply

Tags
forms, tab order

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
unordered list - strange behavior pesho318i Web Page Design 9 Dec 6th, 2007 14:19
Form submit longstand PHP Forum 6 Nov 25th, 2007 01:14
submit many forms - auto submit the same form many times divs JavaScript Forum 0 May 24th, 2007 10:10
how to submit form tobymather Web Page Design 13 Apr 17th, 2007 17:09
Submit Form through EMAIL brunette JavaScript Forum 1 Aug 30th, 2006 19:57


All times are GMT. The time now is 05:31.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43