Advertisement
Guest User

login

a guest
May 13th, 2013
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.40 KB | None | 0 0
  1. <?php
  2. require 'includes/db.php';
  3. require 'includes/init.php';
  4. ?>
  5. <!DOCTYPE HTML>
  6. <html lang="en-US">
  7. <head>
  8.     <meta charset="UTF-8">
  9.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  10.     <title><?php echo $bootername; ?>Login</title>
  11.     <?php include 'includes/css.php'; ?>
  12. </head>
  13. <body>
  14.     <!-- Change Pattern -->
  15.     <!-- Top Panel -->
  16.     <div class="top_panel">
  17.         <div class="wrapper">
  18.             <div class="user">
  19.                 <img src="Images/user_avatar.png" alt="user_avatar" class="user_avatar">
  20.                 <span class="label"><a href="register.php">Sign Up</a></span>
  21.             </div>
  22.         </div>
  23.     </div>
  24.  
  25.     <div class="wrapper contents_wrapper">
  26.         <div class="login">
  27.             <div class="widget_header">
  28.                 <h4 class="widget_header_title wwIcon i_16_login">Login</h4>
  29.             </div>
  30.                     <?php
  31. if (!($user -> LoggedIn()))
  32. {
  33.     if (isset($_POST['loginBtn']))
  34.     {
  35.         $username = $_POST['username'];
  36.         $password = $_POST['password'];
  37.         if (!empty($username) && !empty($password))
  38.         {
  39.             if (!ctype_alnum($username) || strlen($username) < 4 || strlen($username) > 15)
  40.             {
  41.                 echo '<div class="g_12"><div class="error iDialog">Invalid username format</div></div>';
  42.             }
  43.             else
  44.             {
  45.                 $SQLCheckLogin = $odb -> prepare("SELECT COUNT(*) FROM `users` WHERE `username` = :username AND `password` = :password");
  46.                 $SQLCheckLogin -> execute(array(':username' => $username, ':password' => SHA1($password)));
  47.                 $countLogin = $SQLCheckLogin -> fetchColumn(0);
  48.                 if ($countLogin == 1)
  49.                 {
  50.                     $SQLGetInfo = $odb -> prepare("SELECT `username`, `ID`,`status` FROM `users` WHERE `username` = :username AND `password` = :password");
  51.                     $SQLGetInfo -> execute(array(':username' => $username, ':password' => SHA1($password)));
  52.                     $userInfo = $SQLGetInfo -> fetch(PDO::FETCH_ASSOC);
  53.                     if ($userInfo['status'] == 0)
  54.                     {
  55.                         $_SESSION['username'] = $userInfo['username'];
  56.                         $_SESSION['ID'] = $userInfo['ID'];
  57.                         echo '<div class="g_12"><div class="success iDialog">Login successful</div></div><meta http-equiv="refresh" content="2;url=index.php">';
  58.                     }
  59.                     else
  60.                     {
  61.                         echo '<div class="g_12"><div class="error iDialog">ERROR: Your user was banned</div></div>';
  62.                     }
  63.                 }
  64.                 else
  65.                 {
  66.                     echo '<div class="g_12"><div class="error iDialog">ERROR: Login Failed</div></div>';
  67.                 }
  68.             }
  69.         }
  70.         else
  71.         {
  72.             echo '<div class="g_12"><div class="error iDialog">ERROR: Please fill in all fields</div></div>';
  73.         }
  74.     }
  75. }
  76. else
  77. {
  78.     header('location: index.php');
  79. }
  80. ?>
  81.             <div class="widget_contents lgNoPadding">
  82.                 <form action="" method="POST">
  83.                 <div class="line_grid">
  84.                     <div class="g_2 g_2M"><span class="label">User</span></div>
  85.                     <div class="g_10 g_10M">
  86.                         <input name="username" class="simple_field tooltip" title="Your Username" type="text" placeholder="Username"></div>
  87.                     <div class="clear"></div>
  88.                 </div>
  89.                 <div class="line_grid">
  90.                     <div class="g_2 g_2M"><span class="label">Pass</span></div>
  91.                     <div class="g_10 g_10M">
  92.                         <input name="password" class="simple_field tooltip" title="Your Password" type="password" placeholder="Password">
  93.                     </div>
  94.                     <div class="clear"></div>
  95.                 </div>
  96.                 <div class="line_grid">
  97.                     <div class="g_6"><input type="submit" name="loginBtn" class="submitIt simple_buttons" value="Log In" type="submit">
  98.                     </div>
  99.                     <div class="clear"></div>
  100.                 </div>
  101.                 </form>
  102.             </div>
  103.         </div>
  104.  
  105.     </div>
  106. </body>
  107. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement