This topic is locked
[SOLVED]

 Duplicate records in access log

5/23/2007 2:52:04 PM
PHPRunner General questions
S
spoilar author

I have an access log but everytime someone logs in it inserts a duplicate record.
PHPR 3.1 218
After Successful Login event
[codebox]function AfterSuccessfulLogin()

{
//** Insert a record into ab_log table ****

global $conn;
$strSQLInsert = "insert into ab_log (username, access_time, ip_address, browser) values (";

$strSQLInsert .= "'".$_SESSION['UserID']."',";

$strSQLInsert .= "'".date('Y-m-d H:i:s')."',";

$strSQLInsert .= "'".$_SERVER['REMOTE_ADDR']."',";

$strSQLInsert .= "'".$_SERVER['HTTP_USER_AGENT']."')";
db_exec($strSQLInsert,$conn);
}

[/codebox]
my table
--

-- Table structure for table `ab_log`

--
CREATE TABLE `ab_log` (

`username` varchar(50) NOT NULL,

`access_time` datetime NOT NULL,

`ip_address` varchar(50) NOT NULL,

`browser` varchar(255) NOT NULL,

`log_id` int(50) NOT NULL auto_increment,

PRIMARY KEY (`log_id`)

) ENGINE=MyISAM AUTO_INCREMENT=27 DEFAULT CHARSET=latin1;
any ideas why?

J
Jane 5/24/2007

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and send to [email=support@xlinesoft.com]support@xlinesoft.com[/email] a URL to your pages along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.

J
Jepsen 5/25/2007

I have experienced a similar problem.
I log user login and see in the database that some users have duplicate logins. But not always.
After some testing I find that:
If I supply my login credentials and click "Send", only one log-in is registered.
But if I supply my login credentials and press Enter on the keyboard, I am logged in and 2 log-ins are registred.
I do not have the slightest idea why.
Regards

Morten B Jepsen

S
spoilar author 5/25/2007

Yes. I see what you are saying. This seems to be exactly what is happening. Anyone have any idea why it is doing this?
Click "Submit" only one record is inserted.
Press "enter" on the keyboard, and it inserts duplicate(two) records.

Sergey Kornilov admin 5/25/2007

Morten,
sounds pretty strange as data is written to the database after for is submitted and it doesn't matter how it was submitted.
If you have a way to reproduce it publish it to Demo Account and shoot me an email with URL and steps on reproducing this.

S
spoilar author 5/25/2007

Sergey,
I sent the url of the demo account.
It seems if instead of pressing enter immediately after typing the password, you tab to submit, then press enter, it inserts only one record.

S
spoilar author 5/25/2007

I went into Visual Editor for Login (html mode) and removed the following

<INPUT [color=#FF0000]onkeydown="e=event; if(!e) e = window.event; if (e.keyCode != 13) return;

e.cancel = true; document.forms[0].submit();" type=password name=password {$value_password}>


It seems to work. From what I can tell, this would mean if you pressed enter after you typed in your password, it would submit the form.

If this is the case, would this be why it is inserting the record twice? Maybe I am wrong, but would this submit the form twice?
I am probably way off, but at least it isn't inserting two entries.