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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.