Guest User

Untitled

a guest
Apr 8th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. <?php
  2.  
  3. // Inialize session
  4. session_start();
  5.  
  6. // Include database connection settings
  7. include('config.inc');
  8.  
  9. // Retrieve username and password from database according to user's input
  10. $login = mysql_query("SELECT * FROM user WHERE (username = '" . mysql_real_escape_string($_POST['username']) . "') and (password = '" . mysql_real_escape_string(md5($_POST['password'])) . "')");
  11.  
  12. // Check username and password match
  13. $id = mysql_query("SELECT status FROM user");
  14. while($row = mysql_fetch_array($id))
  15.    {
  16.    $status = $row['status'];
  17.    }
  18. if($status==1)
  19. {
  20. if (mysql_num_rows($login) == 1) {
  21.         // Set username session variable
  22.         $_SESSION['username'] = $_POST['username'];
  23.         // Jump to secured page
  24.         header('Location: index.php');
  25. }
  26. else {
  27.         // Jump to login page
  28.         header('Location: login.php');
  29. }
  30. }
  31. else
  32. {
  33. die();
  34. }
  35. ?>
Add Comment
Please, Sign In to add comment