upvote upvote - 4 months ago 18
SQL Question

mysql UPDATE function with DATE_ADD() function

Table structure:

enter image description here

I encounter

DATE_ADD()
function recently while I am searching for a process of how to make a warning in multiple fail login attempts in php. I want to learn how to use this with
mysql UPDATE
function where, first, it sets the
current date
and then it will
add 15 minutes
(interval) so that, the user can't login in the next 15 mins.

update:

example: if the user failed to login 3 times. it will update the user's account that, he/she can log on the next 15 minutues.

this is something code that I think but not working to me

$sql = "UPDATE {$users} SET {$reLoginDate} = DATE_ADD({$reLoginDate}, 15 INTERVAL MINUTE) WHERE {$user} = {$username}";


the
$reLoginDate
is set on current time and will
DATE_ADD()
15 minutues in advance.

Here is the image of my table: 2nd update:
table screen shot

Answer

It's simple thing, try this:

$sql = "UPDATE users
        SET reLoginDate = DATE_ADD(reLoginDate, INTERVAL 15 MINUTE)
        WHERE user = '$username'";
Comments