Jump to content

Login Attempt Problem


Drezard

Recommended Posts

Okay Im creating a script that logs users in. I want a part of the script that if a user fails to put in the correct credentials then it logs it in the database, it logs the time and the users ip. But, I cant think of how I would query the database for all the records with a timestamp 300 seconds old. So, I need a query that checks the database for records less then 300 seconds old. Something like:

 


$timestamp = time() - 300;

$ip = $_SERVER['REMOTE_ADDR'];

// Query here that checks for the records where the timestamp is greater then 300 seconds on

 

Can someone help me?

 

Daniel

Link to comment
https://forums.phpfreaks.com/topic/78027-login-attempt-problem/
Share on other sites

I am not that good to give you the complete solution, but as far you ask for an idea...

 

go to http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

 

and see the function NOW you will see that it works like

 

mysql> SELECT NOW();

        -> '1997-12-15 23:50:26'

mysql> SELECT NOW() + 0;

        -> 19971215235026

 

also with the help of php function strtotime() you can have the below idea

$NowAttemp = mysql> SELECT NOW() + 0; Make it appropriate

$previousAttemp = strtotime(timestampFromDB)

 

if (($NowAttemp - $previousAttemp) < 300 ) {mpla mpla}

Link to comment
https://forums.phpfreaks.com/topic/78027-login-attempt-problem/#findComment-394929
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.