Page 1 of 1

Query executes twice with IE

Posted: Tue Jul 25, 2006 5:01 am
by someberry
I have tried the code in quite a few browsers, and this error only effects IE. For some reason, the query is executed twice. I have pinpointed it to when I press the enter key on one of the inputs instead of clicking the submit button directly.

I have also tried adding a simple echo statement just before the query, it only ever prints it out once.

This is the code I am using:

The form

Code: Select all

<p>Subject<br />
<input type="text" name="subject" /><br />
Message<br />
<textarea name="message" rows="10" cols="45"></textarea><br />
<input type="submit" name="submit" value="Submit" />
The class caller

Code: Select all

$mail = new Mail();
$mail -> send_msg();
The class

Code: Select all

class Mail
{
	var $msg;	// Store any error/success messages
	
	function __construct() { /* Dont do anything */ }
	
	function send_msg()
	{
		// Send the message
		mysql_query("INSERT INTO `mail`(`subject`,									`message`)
								 VALUES('" . htmlentities($_POST['subject']) . "',	'" . htmlentities($_POST['message']) . "')
					") or die(mysql_error());
									    
		$this -> msg = '<p><span class="notice">Success</span>: mail sent successfully.</p>';
	}
}
?>
As you can see, it is pretty basic stuff. However, IE seems to replicate the exact query, which is very fustrating. I am using ApacheFriends XAMPP Lite version 1.5.2 as my localhost (which is PHP5), but the problem remains even on my server which is running PHP4.

Does anyone have any ideas why this might be happening?
Thanks,
someberry

Posted: Tue Jul 25, 2006 5:11 am
by hairyjim
What version of IE are you using? Are you perhaps using IE 7?

Posted: Tue Jul 25, 2006 5:15 am
by JayBird
What does the whole script look like? Post it here

Posted: Tue Jul 25, 2006 5:15 am
by Benjamin
Do you think IE is posting data twice?

Posted: Tue Jul 25, 2006 5:15 am
by Benjamin
Yargh

Posted: Tue Jul 25, 2006 5:16 am
by JayBird
Hehe, firefox

Posted: Tue Jul 25, 2006 6:14 am
by someberry
Oh dear, this is rather embarrassing. :oops:

Thanks to hairyjim who got my brain into gear with what version of IE I was using. I was using IE via Firefox's IETab extention. Seems it maybe posts it using Firefox and IE. Oops.

Just tried it on the real IE and it works.

Thanks everyone,
someberry