Skip to content

Instantly share code, notes, and snippets.

@alexguichet
Last active June 21, 2019 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexguichet/15e56ed640a9a56b410600b780cf3ffb to your computer and use it in GitHub Desktop.
Save alexguichet/15e56ed640a9a56b410600b780cf3ffb to your computer and use it in GitHub Desktop.
<?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