php - Create cron job to automatically unban users after a certain date? -
i have site mysql database. have spot in admin panel administrators can ban users. when bans user makes column "banned"=1 , "banneduntil"= week after ban date. want create cron job runs maybe every night unban users whos bans have expired.
far have doesn't seem work:
$db_con = mysqli_connect($db_host, $db_user, $db_pass) or die("it failed."); $today = date('y-m-d'); mysqli_query ($db_con, "update users set banned='0' banneduntil < '$today'");
i using cpanel.
edit: date stored in database in format: "2014-03-24"
modify query this
mysqli_query ($db_con, "update users set banned='0' banneduntil < now();")
and should work.
Comments
Post a Comment