Code: Select all
<?php
if ($_SERVER['REQUEST_METHOD'] == "POST") //If it was posted to set the cookie
{
$check = $_POST['set']; //The 'set' is if the user wants to be remembered
if($check=='ON')
{
$name = $_POST['name'];
$pass = md5($_POST['pass']);
$cookie_data = $name.'-'.$pass;
setcookie("user", $cookie_data); //No expiration
}
else
{
$name = $_POST['name'];
$pass = md5($_POST['pass']);
$cookie_data = $name.'-'.$pass;
setcookie ("user", $cookie_data, time() + 3600); //Expire after 1 hour
}
}
echo "<HTML>";
echo "<HEAD>";
echo "<link rel='stylesheet' type='text/css' href='Style.css'>";
echo "<TITLE>Members Only</TITLE>";
require "header.php"; //Page with all the html code for the head and some body
require "body.php"; //Page with all the html code for the body up until:
----- All my login code (Enter name & password, authenticate etc) -----
require "footer.php"; //The rest of the HTML code
?>