Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (isset($_POST['password']) && $_POST['password'] == 'MYPASS') { // We check here if the password entered matches 'MYPASS' and if so we set a cookie for 30 days.
- setcookie("password", 'MYPASS', strtotime('+30 days'));
- header('Location: '.$_SERVER['PHP_SELF']);
- exit;
- }
- if ($_GET['q'] !== 'VALUE'){ // Here we check if 'index.php?q' has a value of 'VALUE' and if not we ask for password.
- // Simple password protection
- if (!isset($_COOKIE['password']) || $_COOKIE['password'] !== 'MYPASS') {
- echo' <html>
- <head>
- <title>Password protected</title>
- </head>
- <body>
- <div style="text-align:center;margin-top:50px;">
- You must enter the password to view this content.
- <form method="POST">
- <input type="text" name="password">
- </form>
- </div>
- </body>
- </html>';
- exit;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement