View Single Post
Old 03-17-2006, 01:26 PM   · #4
tm
Senior Member
 
tm's Avatar
 
Name: TheMoose
Location: on a oil rig just off Ireland
Trader Rating: (24)
Join Date: Nov 2005
Posts: 1,409
NP$: 374.65 (Donate)
tm is a glorious beacon of lighttm is a glorious beacon of lighttm is a glorious beacon of lighttm is a glorious beacon of lighttm is a glorious beacon of light
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!');
     }
}
?>


Please register or log-in into NamePros to hide ads
__________________
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.
tm is offline   Reply With Quote
Site Sponsors
Skilled Graphics http://www.domainate.com/y/ Skilled Graphics
Advertise your business at NamePros
All times are GMT -7. The time now is 11:28 PM.


Powered by: vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.