A
Anonymous
Guest
ello guys...i have problem to check if the user already login to the system or not. if the user already login, she/he cannot login for the second time at the same time...anyybody knows how to check it???? :help: ...below i have attached my codes to verify user before login. where actually i can add the codes to check the login only allowed once at one time????
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Code:
<?php
if (!session_start()){
session_start();
}
include ("db_connect.php");
$rc = 0;
$msg = "";
if (isset($_POST["mybutton"])){
$username = trim($_POST["name"]);
$password = trim($_POST["pass"]);
if ($username !=""){
$SQL = "SELECT * FROM login_dc WHERE (username = '$username') AND (password = '$password')";
$rs = mysql_query($SQL);
if ($row = mysql_fetch_array($rs,MYSQL_ASSOC)){
$_SESSION["un"] = $row["username"];
$_SESSION["pw"] = $row["access"];
}
else
$rc = 2;
}
else
$rc = 1;
}
if (isset($rs)) mysql_free_result($rs);
if ($rc == 0){
header ("location: save.php");
exit;
}
else{
if ($rc == 1) $msg = " ** Please Specify Username ...";
if ($rc == 2) $msg = " ** Invalid Username or Password ...";
header("location: login.php?msg=$msg");
}
?>