I have this script
<?php
$username = "namey";
$password = "passy";
$salted = "salty";
if (isset($_COOKIE['Cookiename'])) {if ($_COOKIE['Cookiename'] == sha1($password.$salted)) {
?>
<body>
<span>
it works
</span></body>
<?php
exit;}
else {
echo "Bad Cookie, Baaad lol";
exit;}}
if (isset($_GET['auth']) && $_GET['auth'] == "login") {
if ($_POST['user'] != $username) {
echo "The Provided Username Was Not Correct.";
exit;}
else if ($_POST['keypass'] != $password) {
echo "The Provided Password Was Not Correct.";
exit;}
else if ($_POST['user'] == $username && $_POST['keypass'] == $password) {
setcookie('Cookiename', sha1($_POST['keypass'].$salted));
header("Location: $_SERVER[PHP_SELF]");}
else {
echo "Something's wrong with the server.";}}
?>
<div>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?auth=login" method="post">
<label>Username<input type="text" name="user" id="user" /></label><br/>
<label>Password<input type="password" name="keypass" id="keypass" /></label><br/>
<input type="submit" id="submit" value="Login"/>
</div>
</form>
& basically i need every link on the site to come though here & look if the user is logged in before letting him access any page he requested.
i have just started learning PHP & right now i am confused, the code you see on top is a code i have seen here on this website
i googled for a way to do this but no results