Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.92 KB | None | 0 0
  1. <?php
  2. $msg = "";
  3. if(protect($_POST['login']))
  4. {
  5. $username = protect($_POST['username']);
  6. $password = protect($_POST['password']);
  7.  
  8. if ($username&&$password)
  9. {
  10. session_start();
  11.  
  12. $query = mysql_query("SELECT * FROM users WHERE username='$username'");
  13. $numrows = mysql_num_rows($query);
  14. $password = md5($password);
  15. if($numrows!=0)
  16. {
  17.   // code to login
  18.        $row = mysql_fetch_assoc($query);
  19.        $dbusername = $row['username'];
  20.        $dbpassword = $row['password'];
  21.        $activated = $row['activated'];
  22.        $admin = $row['admin'];
  23.        if ($activated == '0')
  24.        $msg = "<div class='error'>You have not activated your account. Please check your e-mail to do so.<br><a href='index.php?action=Resend'>Click here to resend your activation e-mal.</a></div>";
  25.  
  26.  
  27.      //check to see if they match !
  28.      if ($username == $dbusername && $password == $dbpassword )
  29.       {
  30.       if ($activated == '1')
  31.        {
  32.        $_SESSION['username']=$username;
  33.        if ($admin>=1)
  34.         $_SESSION['admin']=$admin;
  35.            header("Location: /quarters.php");
  36.         mysql_query("UPDATE users SET online='online' WHERE username='$username'");
  37.        }
  38.  
  39.      }
  40.      else
  41.     $msg = "<div class='error'>Incorrect password!</div>";
  42. }
  43. else
  44. $msg = "<div class='error'>That user doesn't exist!</div>";
  45. }
  46. else
  47. $msg = "<div class='error'>Please enter a username and password.</div>";
  48. }
  49.  
  50. // <table valign='top'> <tr> t<d> </td><td> </td><td>   </td><td>  </td><td></table>    </td>
  51. echo "
  52. <p>
  53. <center>
  54. <form action='index.php' method='POST'>
  55. <fieldset id='login'>
  56. <legend><b>Log-In</b></legend>";
  57. if ($msg)
  58. echo $msg;
  59.  
  60. if (!$_SESSION['username']){
  61.     echo "Username: <input type='text' name='username' value='$username'>
  62.    Password: <input type='password' name='password'>
  63.    <input type='submit' name='login' value='Log in'>";
  64.     }
  65. else
  66. echo "You are already logged in. <a href='/quarters.php' target='_self' title='Quarters'>Click here to continue to your quarters.</a>";
  67.     echo "</fieldset>";
  68. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement