Skip to content

Instantly share code, notes, and snippets.

Created December 25, 2013 08:42
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 anonymous/8121436 to your computer and use it in GitHub Desktop.
Save anonymous/8121436 to your computer and use it in GitHub Desktop.
<?php
session_start();
$password = "booga";
//sessions
if(isset($_SESSION['loggedIn'])) {
$loggedIn = true;
} else {
$loggedIn = false;
}
//password shit
if (isset($_POST['PFormSubmit'])) {
if ($_POST['PFormPass'] == $password) {
$_SESSION['loggedIn'] = true;
$loggedIn = true;
}
}
//if user logged out
if (isset($_POST['logoutSubmit'])) {
session_unset();
session_destroy();
session_write_close();
$loggedIn = false;
}
?>
<!--This preliminary HTML is always shown:-->
<html>
<head>
<title>TITLE</title>
</head>
<body>
<!--//The above preliminary HTML is always shown
The below HTML shows the logout button, if the user is logged in.-->
<?php if($loggedIn) { ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="submit" name="logoutSubmit" value="logout" />
</form>
<?php } //if logged in ?>
<?php if(!$loggedIn) { ?>
<!-- This shows the login form if the user is not logged in -->
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<h3>Password</h3>
<input type="password" name="PFormPass" />
<input type="submit" name="PFormSubmit" />
</form>
<?php }
if ($loggedIn) { ?>
<!-- THIS IS WHERE YOUR SECRET SHIT GOES -->
<!-- THIS IS WHERE YOU SECSRET SHIT ENDS -->
<?php } //if logged in ?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment