Advertisement
Aha2Y

Untitled

Mar 8th, 2012
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.69 KB | None | 0 0
  1. <?php
  2. session_start();
  3. if($_SERVER['QUERY_STRING'] == "logout") {
  4.     unset($_SESSION['authuser']);
  5.     header("Location: " . $_SERVER['PHP_SELF']);
  6.     exit;
  7. }
  8. $username = $_POST['username'];
  9. $password = $_POST['password'];
  10. $login    = $_POST['login'];
  11. if($_SESSION['authuser'] != $adminuser) {
  12.     if(!$login) {
  13.         loginpage(false);
  14.     }
  15.     elseif(($username != $adminuser) || ($password != $adminpass)) {
  16.         loginpage(true);
  17.     }
  18.     else {
  19.         $_SESSION['authuser'] = $adminuser;
  20.         header("Location: " . $_SERVER['REQUEST_URI']);
  21.     }
  22. }
  23. header( 'index.php' ) ;
  24. session_write_close();
  25. ?>
  26. $adminuser = "test";
  27. $adminpass = "test";
  28.  
  29.  
  30. function loginpage($error) {
  31.     echo "<html>\n<head>\n<title>Admin panel - Please login</title>\n";
  32.     echo "</head>\n<body>\n";
  33.     echo "<table style='width:100%;height:100%;'>\n<tr>\n<td align='center'>\n";
  34.     echo "<form action='" . $_SERVER['REQUEST_URI'] . "' method='post'>\n";
  35.     echo "<table border='1' width='300' cellspacing='0' cellpadding='4'><tr>\n";
  36.     $formtitle = "Admin panel - Please login";
  37.     if($error) $formtitle = "Wrong credentials!";
  38.     echo "<th colspan='2'>" . $formtitle . "</th>\n";
  39.     echo "</tr><tr>\n";
  40.     echo "<td><p><b><label for='username'>Username:</label></b></p></td>\n";
  41.     echo "<td><input type='text' name='username' id='username' size='30'></td>\n";
  42.     echo "</tr><tr>\n";
  43.     echo "<td><p><b><label for='password'>Password:</label></b></p></td>\n";
  44.     echo "<td><input type='password' name='password' id='password' size='30'></td>\n";
  45.     echo "</tr><tr>\n";
  46.     echo "<td><b>Login:</b></td>\n";
  47.     echo "<td><input type='submit' value=' Login &raquo; ' name='login'></td></tr></table></form>\n";
  48.     echo "</td>\n</tr>\n</table>\n</body>\n</html>";
  49.     exit;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement