Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Very simple password protectetion for very simple php web pages
- */
- $accessWord = 'nameOfMyGirlfriendOrDaughterWhereEsAreReplacedByThrees';
- if (!isset($_COOKIE['accessWord']) || $_COOKIE['accessWord'] !== md5($accessWord)) {
- if (isset($_POST['accessWord']) && trim($_POST['accessWord']) === $accessWord) {
- setcookie('accessWord', md5($accessWord), time() + (7 * 24 * 3600));
- } else {
- echo '<meta charset="utf-8">';
- echo '<meta name="viewport" content="width=device-width, initial-scale=1">';
- echo '<style>';
- echo 'html { font-size: 20px; line-height: 1.5em; box-sizing: border-box; }';
- echo '*, *:before, *:after { box-sizing: inherit; }';
- echo 'input { font-size: 20px; line-height: 2.5em; padding: 0 0.5em; display: block; margin-bottom: 0.5em; }';
- echo 'input[type="submit"] { padding: 0.5em; }';
- echo '</style>';
- echo '<h1>Please enter accessword</h1>';
- echo '<form method="post" action="">';
- echo '<input type="password" name="accessWord" />';
- echo '<input type="submit" value="Send" />';
- echo '</form>';
- exit;
- }
- }
- // continue here the rest of your php code. Remove above when there is no need for password protection any longer
- ?>
- <h1>Hi, welcome on my web site</h1>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement