Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $user["stackoverflow"] = "isawesome";
- if (!isset($_SESSION['logged_in']))
- {
- if ($_SERVER['REQUEST_METHOD'] == 'POST')
- {
- if (empty($_POST['username']) || empty($_POST['password']))
- {
- exit('<br /><br /><html><body><div id="center"><h2> Login Status: <br/></h2><span style="color:red; font-weight: bold">Please fill in all fields!</span></div><meta http-equiv="refresh" content="1"></body>');
- }
- elseif ($user[$_POST['username']] != $_POST['password'])
- {
- exit('<br /><br /><div id="center"><h2> Login Status: <br/></h2><span style="color:red; font-weight: bold">Your username/password is wrong!</span></div><meta http-equiv="refresh" content="1"></body>');
- }
- else
- {
- $_SESSION['ingelogd'] = true;
- echo '<div id="center"><h2> Login Status: <br/></h2><span style="color:green; font-weight: bold">You are now logged in!</span></div>';
- if(!isset($_COOKIE['ingelogd'])){
- setcookie("ingelogd", "ingelogd", time() + (10 * 365 * 24 * 60 * 60));
- die(header("Location: /index.html"));
- }
- }
- }
- else
- {
- exit('<br /><br />
- <link rel="stylesheet" href="/css/body.css">
- <link rel="stylesheet" href="/css/button.css">
- <div id="center">
- <form method="POST" action=""><p>
- Username:<br />
- <input type="text" name="username" /><br /><br />
- Password:<br />
- <input type="password" name="password" /><br /><br />
- <input type="submit" value="Login" /> <input type="reset" value="Empty fields" />
- </form></div>');
- }
- }
- ?>
- <link rel="stylesheet" href="/css/body.css">
- <?php
- session_start();
- //if user is logged in, "user" toolbox will show
- if (isset($_SESSION['ingelogd']) && $_SESSION['ingelogd'] == true) {
- echo "<ul id="menu">
- <li class="li"><a class="active" href="#home">Home</a></li>
- <li class="li"><a id="a" href="html/info/news.html">News</a></li>
- <li class="li"><a id="a" href="html/info/contact.html">Contact</a></li>
- <li class="li"><a id="a" href="html/info/about.html">About</a></li>
- <li class="li"><a id="a" href="html/auth/logout.php" style="float:right">Log out</a></li>
- </ul>
- <br/>";
- }
- //if not logged in, this will show
- else {
- echo "<ul id="menu">
- <li class="li"><a class="active" href="#home">Home</a></li>
- <li class="li"><a id="a" href="html/info/news.html">News</a></li>
- <li class="li"><a id="a" href="html/info/contact.html">Contact</a></li>
- <li class="li"><a id="a" href="html/info/about.html">About</a></li>
- <li class="li"><a id="a" href="html/auth/login.php" style="float:right">Log in</a></li>
- </ul>
- <br/>";
- }
- ?>
- <link rel="stylesheet" href="/css/menu.css">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement