我有这样的代码:
include ("config.php");
$username = $_POST['username'];
$password = $_POST['password'];
$do = $_GET['do'];
if($do=="login")
{
$cek = mysql_query("SELECT password, user_level FROM t_users WHERE username='$username' AND password='$password'");
if(mysql_num_rows($cek)==1)
{
$c = mysql_fetch_array($cek);
$_SESSION['username'] = $c['username'];
$_SESSION['user_level'] = $c['user_level'];
if($c['user_level']=="supervisor")
{
header("location:supervisor.php");
}
else if($c['user_level']=="user")
{
header("location:home.php");
}
else if($c['user_level']=="root")
{
header("location:administrator.php");
}
else if($c['user_level']=="manager")
{
header("location:manager.php");
}
else if($c['user_level']=="admin")
{
header("location:admin.php");
}
else if($c['user_level']=="director")
{
header("location:director.php");
}
}
else
{
header('Location: index.html');
}
}
else if($do=="logout")
{
date_default_timezone_set("Asia/Jakarta");
$last_logged_out = date("j-F-Y, G:i ");
$ip_address=$_SERVER['REMOTE_ADDR'];
mysql_query("update t_users set last_logged_out='$last_logged_out', ip_address='$ip_address' WHERE username='$_SESSION[username]'");
unset($_SESSION['username']);
unset($_SESSION['user_level']);
header("location:index.html");
}
如果有人登录并且在同一时间或不同时间有人使用相同的用户名登录然后我希望系统将通知该用户已经登录,那么我如何提供功能代码,因此具有相同用户名的用户无法登录直到用户注销之前。
有人可以帮助我吗?谢谢你。