用php制作一个日志文件

时间:2012-09-12 04:59:51

标签: php mysql

我的注册页面如下所示

$checkForUser = mysql_query("SELECT id FROM `users` WHERE `username`='{$posts['username']}' OR `email`='{$posts['email']}'");
$checkForUserRows = mysql_num_rows($checkForUser);

$ip = VisitorIP();
$checkForIP = mysql_query("SELECT id FROM `users` WHERE `ip`='{$ip}'");
$checkForIPRows = mysql_num_rows($checkForIP);

if ($checkForUserRows > 0) {
    $error = "Username or email already registered!";
}else if ($checkForIPRows > 0)  {
    $error = "You may only have one account! This attempt has been logged. You will be banned! ";

我想自动禁止其IP已存在的帐户,并出现以下错误$error = "You may only have one account! This attempt has been logged. You will be banned! ";

1 个答案:

答案 0 :(得分:0)

只需用fwrite http://php.net/manual/en/function.fwrite.php

写一个日志文件

要禁止ip,您需要在代码的开头进行ip检查。您应该将bool列添加到数据库“banned”。