I use PHP for login/access control. The basic idea is like so:
1) choose a password for your page (or even your whole site).
2) use the md5 or sha1 function to generate a "hash" of your password (ex.: <?php echo md5('mypassword'); ?> -that will generate something like 9e107d9d372bb6826bd81d3542a419d6, depending on the password you choose ).
3) nest the content you wish to protect in a conditional statement, like so:
PHP Code:
// check if the user submitted a password
if(isset($_POST['password'])){
// if so, check if hash of submitted password matches choosen password hash
if(md5($_POST['password']) == '9e107d9d372bb6826bd81d3542a419d6'){
// if so, show page content here.
// otherwise,
}else{
// show an error message
echo 'WRONG PASSWORD!';
// and end the script (content is never seen)
die;
}
// if the user didn't give a password
}else{
// show the login form
echo'
<form action="'.$_SERVER['PHP_SELF'].'" method="POST">
Enter your password:
<input type="password" name="password">
<input type="submit" value="Log In">
</form>
';
}
this is obviously very brief; and not overly efficient, but it give the concept of how to password-protect a php page. Do a google search for "php password script" to find something ready-to-go. Have fun!
Bookmarks