PHP-Code:
function logged() {
if(!session_is_registered(userid)) {
return false;
}
return true;
}
function login($username = "", $password = "") {
global $conn;
if(empty($username) || empty($password)) {
return false;
}
$password = md5($password);
$select = "SELECT userid FROM user WHERE username = '".addslashes($username)."' AND password = '".addslashes($password)."' LIMIT 1";
$result = @mysql_query($select);
if(!@mysql_num_rows($result)) {
return false;
}
while($row = mysql_fetch_array($result)) {
$userid = $row["userid"];
}
$_SESSION["userid"] = $userid;
return true;
}
function logout() {
session_unregister(userid);
}
Kommentar