| Senior Member Name: TheMoose Location: on a oil rig just off Ireland Join Date: Nov 2005
Posts: 1,409
NP$: 374.65 ( Donate)
| Hey,
The script would be good for an admin panel or something similar.
I might like to make a few additions to your script  - add cookies so you won't have to login every time. the 3600 is in seconds - that's an hour. Change if you wish. (86400 is a day). PHP Code: <?php
// Let's define the page that we will see the login form & page title
$pagetitle = "Page Title Here";
setcookie("TestCookie", "hello");
if(empty($_COOKIE['TestCookie'])) { die("Cookies disabled!"); } else { setcookie("TestCookie", "hello", time()-3600); }
if(empty($_COOKIE['adminformpassword'])){ ?>
<HTML>
<TITLE><?php echo($pagetitle); ?></TITLE>
<BODY>
<form name="login" method="post" action="?page=login">
Password: <input type=password name="password"><br>
<input type=submit value="Login"><input type=reset>
</form>
</BODY>
</HTML>
<?php
// Let's end that section with the following bracket
}
// Start the login page
if($page == "login"){
// The value '$password' comes from name="password" in the password field
$password = $_POST['password'];
if($password == "YourPasswordHere") {
setcookie("adminformpassword", md5($password), time()+3600);
}
if(md5($password) != $_COOKIE['adminformpassword']){
echo('Incorrect Password');
exit;
}
else
{
echo('You are now logged in!! Page content goes here!');
}
}
?>
__________________ You design in photoshop, I code into valid XHTML/CSS. Professional PSD, PNG or HTML to tableless XHTML/CSS designs. For more info, send me a PM. |