Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Password Protection (See related posts)

// Bare Bones demo of password protection

<?php
$password = "abc123";
if ($_POST[doddle] == $password) {
        $tell = 1;
} else {
        $tell = 2;
}
if (! is_string($_POST[doddle])) $tell = 0;
?>
<html>
<head><title>A Page that is password protected</title></head>
<body>
<?php if ($tell == 1) { ?>
 
<h1>The page with all the secrets revealed </h1>
 
This is the information that has been revealed to you because you
got the password right!<br /><br />Although this is a very simple
demo it shows what you can do with just a few lines of PHP.
 
<?php } else { ?>
 
<h1>A Header page</h1>
 
There is a page hidden under a password at this URL. For this demo only
I will tell you that the password is "abc123" so you can try it out!<br />
<?php if ($tell == 2) print ("<br />YOU GOT THE PASSWORD WRONG<br />"); ?>
<br />
<form method=post>
Please enter password <input type=password name=doddle>
<input type=submit value=go>
</form>
 
<?php } ?>
 
<hr />
<a href=http://www.wellho.net>Well House Consultants</a>, 2007
</body>
</html>

You need to create an account or log in to post comments to this site.


Click here to browse all 5147 code snippets

Related Posts