SHARE
TWEET

Untitled

a guest Jun 15th, 2017 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $auth = false; //login status
  3.  
  4. if ($_SERVER['REQUEST_METHOD'] == 'POST')
  5. {
  6.     mysql_connect('127.0.0.1', 'root', '');
  7.     mysql_select_db('test');
  8.  
  9.     //get data from db
  10.     $query = 'SELECT password,salt FROM users WHERE username =' . mysql_escape_string($_POST['username']) . ' LIMIT 1';
  11.     $data = (object) mysql_query($query);
  12.  
  13.     if ($data->password === md5($_POST['password'] . $data->salt))
  14.     {
  15.         $auth = true;
  16.     }
  17. }
  18. ?>
  19.  
  20. <?php if ($auth): ?>
  21.     Login success
  22. <?php else: ?>
  23.         <form method="POST" action="/">
  24.             <label>Username:</label>
  25.             <input type="text" name="username" />
  26.             <label>Password:</label>
  27.             <input type="password" name="password" />
  28.         </form>
  29. <?php endif; ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top