-
-
Save alexguichet/15e56ed640a9a56b410600b780cf3ffb to your computer and use it in GitHub Desktop.
don't use this. (context, https://tildes.net/~comp/er5/need_a_simple_way_to_password_protect_a_webpage#comment-3hc7)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// SET THIS AS YOUR PASSWORD | |
$password = "your_password_here"; | |
// State Tracking Variables | |
$showContents = isset($_POST["password"]) && $_POST["password"] === $password ? true : false; | |
$incorrectPassword = isset($_POST["password"]) && $_POST["password"] !== $password ? true : false; | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>This is a page.</title> | |
</head> | |
<body> | |
<?php if ($showContents): ?> | |
<h3>These are the secret contents that will not appear uneless the user has entered the correct password.</h3> | |
<?php endif; ?> | |
<?php if ($incorrectPassword): ?> | |
<h3>Your password is incorrect.</h3> | |
<?php endif; ?> | |
<form action="secret.php" method="post"> | |
Password: <input type="password" name="password"> | |
<button type="submit" value="submit"></button> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment