Query executes twice with IE
Posted: Tue Jul 25, 2006 5:01 am
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
The class caller
The class
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
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" />Code: Select all
$mail = new Mail();
$mail -> send_msg();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>';
}
}
?>Does anyone have any ideas why this might be happening?
Thanks,
someberry