but now i want to have something that checks if a user is logged in or not - and if the user is NOT then i want him to go to the login page. so i thought about somethig like this:
Code: Select all
<?php
function CheckUserSession ($session) {
$result = mysql_query("SELECT UserId,Name,Vorname,UserName,UserLogin FROM AdminUser
WHERE UserSession = '".$session."'") or mysql_error();
if ( mysql_num_rows($result) == 1 ) {
////<code for adding a dataset>
}
else {
header ("Location: /site/index_login.php");
return false;
}
}
?>do i have the right idea?? .. cause with this, its not working so far - the script adds the data ... logged in or not.
or can i even have this code in my external login script ???
and tell the script always to go to login page if user is not logged in???