Wednesday, July 7, 2010

Password protect a page

Description

Password protection for a single page. Visitors are required to enter a password

and username into a login form to view the page content.

The code


// Define your username and password
$username "someuser";
$password "somepassword";
if ($_POST['txtUsername'] != $username ||
 $_POST['txtPassword'] != $password) {?>
 
Login 
 
echo $_SERVER['PHP_SELF']; ?>">

    Username:  
    Password:
   }
else {  This is the protected page. Your private 
content goes here.

}


 

No comments:

Post a Comment