Advertisement
Guest User

Untitled

a guest
Apr 10th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['username']) && isset($_POST['password'])){
  3. require_once('includes/db.connect.php');
  4.  
  5. $username = $_POST['username'];
  6. $password = $_POST['password'];
  7.  
  8. $query_accounts_select = "SELECT id, type, username, password, email, phone, address, area, city FROM accounts WHERE username='$username' AND password=MD5('$password') AND verified=1 LIMIT 1";
  9. $result_accounts_select = mysqli_query($connect, $query_accounts_select);
  10. $count_accounts_select = mysqli_num_rows($result_accounts_select);
  11.  
  12. $error_message = 'The username or password you entered does not match.';
  13.  
  14. if($count_accounts_select == 1){
  15. $row_accounts_select = mysqli_fetch_array($result_accounts_select);
  16. mysqli_close($connect);
  17.  
  18. $_SESSION['id'] = $row_accounts_select['id'];
  19.  
  20. if($row_accounts_select['email'] == ''
  21. || $row_accounts_select['phone'] == ''
  22. || $row_accounts_select['address'] == ''
  23. || $row_accounts_select['area'] == ''
  24. || $row_accounts_select['city'] == ''){
  25. $_SESSION['profile_complete'] = false;
  26. }
  27. else{
  28. $_SESSION['profile_complete'] = true;
  29. }
  30.  
  31. if($row_accounts_select['type'] == 'admin'){
  32. $_SESSION['admin'] = $row_accounts_select['username'];
  33. $_SESSION['user'] = $row_accounts_select['username'];
  34. }
  35. elseif($row_accounts_select['type'] == 'user'){
  36. $_SESSION['user'] = $row_accounts_select['username'];
  37. }
  38.  
  39. if(isset($_POST['redirect'])){
  40. header('Location: '.$base.$_POST['redirect']);
  41. exit;
  42. }
  43. else{
  44. if($row_accounts_select['type'] == 'user'){
  45. header('Location: '.$base);
  46. exit;
  47. }
  48. else{
  49. header('Location: '.$base.'account');
  50. exit;
  51. }
  52. }
  53. }
  54. else{
  55. header('Location: '.$_SERVER['HTTP_REFERER'].'?action=error&message='.$error_message);
  56. exit;
  57. }
  58. }
  59. else{
  60. header('Location: '.$_SERVER['HTTP_REFERER'].'?action=error');
  61. exit;
  62. }
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement