This code will block the account.
<?php
if($_POST['submit'])
{
$delay = $_POST['delay'];
$account_id = 1234;
$start_date = date("Y-m-d H:i:s");
$end_date = date("Y-m-d H:i:s", strtotime("$delay day"));
$sql01 = mysql_query("INSERT INTO account.frozenaccounts (`account_id`, `start_date`, `end_date`) VALUES ($account_id, $start_date, $end_date)");
$sql02 = mysql_query("UPDATE account.account SET status = 'BLOCK' WHERE id = $account_id");
if($sql01 && $sql02)
{
echo "Your account is blocked for $delay days.<br><br>";
}
else
{
echo "sql error";
}
}
?>
<form action="page1.php" method="POST">
<select name="delay">
<option value="1">1 day</option>
<option value="2">2 day</option>
<option value="3">3 day</option>
<option value="7">1 week</option>
</select>
<input type="submit" name="submit" value="Submit"/>
</form>
This code will unblock the frozen chars which's delay has expired:
<?php
$now = date("Y-m-d H:i:s");
$query = mysql_query("SELECT * FROM account.frozenaccounts WHERE end_date <= $now");
if(mysql_num_rows($query) > 0)
{
//there are minimum one account which is frozen, and you have to unfroze it
while($array = mysql_fetch_array($query))
{
$accountid = $array['account_id'];
$query2 = mysql_query("DELETE FROM account.frozenaccounts WHERE account_id = $accountid");
$query3 = mysql_query("UPDATE account.account SET status = 'OK' WHERE id = $accountid");
}
}
?>
If you won't open the page, where the second code is placed, it won't unfreeze the accounts. So you need to open it about once a day. If you open it for example 24 times a day, it will works perfectly, because if i freeze my account today at 8PM, and you will open it tomorrow at 7PM, my account won't unfreeze, so i have to wait to the next day. In my opinion 24 times per day would be ideal for this script.