Hi JJ,
ok now I know:
at first get the login and password via HTML:
<form action="login.php3" method="post">
name: <input type="text" size="10" name="user">
login: <input type="password" size="10" name="login">
<input type="submit" value="login">
</form>
then log the person in via
<?
function login_first() {
global $user, $login;
if ($user) {
if ($login=="password") {
$success=setcookie("user",$user,time()+28800);
$ok="ok";
} else {
$ok=false;
}
}
return $ok;
}
$ok=login_first();
then test the $ok if everything is OK:
<? if ($ok!="ok") { echo "sorry wrong password or login <a href='login.htm'>back</a>"; exit; } ?>
on every other page, after the login begin with:
$ok=login_test();
function login_test() {
global $user, $login;
$hallo=setcookie("user",$user,time()+28800);
if ($name) {
$ok="ok";
} else {
echo "Cookie not set";
$ok="nope";
exit;
}
}
if the user is logged in the variable $user exists and you can show the page content, if not just redirect him again to the login.
to log out use this:
function logout() {
global $user, $login;
$ok=setcookie("user","",time()+1);
}
hope this helps, if you have questions, you can ask me
Andreas