MySQL Triggers to Disable A User Account

Posted by Mike D on Stack Overflow See other posts from Stack Overflow or by Mike D
Published on 2010-04-06T21:05:57Z Indexed on 2010/04/06 21:23 UTC
Read the original article Hit count: 363

Filed under:
|

I am trying to create a MySQL Trigger to disable someone's account if they have logged in to the site 3 times. I have tried to create this trigger using the following code, but it is not setting is_active to 0 no matter what times_logged_in is. Any help would be appreciated.

CREATE TRIGGER updateTrigger AFTER UPDATE ON users
FOR EACH ROW
BEGIN
UPDATE users SET is_active=0 WHERE NEW.is_code=1 
AND NEW.times_logged_in>=3
AND NEW.user_id=user_id;
END;

© Stack Overflow or respective owner

Related posts about mysql

Related posts about trigger