Guest User

Untitled

a guest
Dec 27th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. if(isset($_POST['login'])){
  2.  
  3. $link = $_SERVER['HTTP_REFERER'];
  4. $base_url = strtok($link, '?'); // Get the base url
  5. $parsed_url = parse_url($link); // Parse it
  6. $query = $parsed_url['query'];
  7.  
  8. if(!isset($query)){
  9. $redireciona=$link;
  10. }else{
  11. $redireciona=substr($link, 0, strpos($link, "failed") - 1);
  12. }
  13.  
  14. $user = trim($_POST['sp_uname']);
  15. $pass = trim($_POST["sp_pass"]);
  16. $stmt = $ligadb->prepare("SELECT id_user, u_user, u_nome, u_password, u_perfil FROM users WHERE u_user=? LIMIT 1");
  17. $stmt->bind_param('s', $user);
  18. $stmt->execute();
  19. $stmt->bind_result($user_id, $user, $nome, $password, $perfil);
  20. $stmt->store_result();
  21. if($stmt->num_rows == 1) //To check if the row exists
  22. {
  23. if($stmt->fetch()) //fetching the contents of the row
  24.  
  25. {
  26. if(password_verify($_POST["sp_pass"], $password)){
  27. $_SESSION['user'] = $user;
  28. $_SESSION['perfil'] = $perfil;
  29. $_SESSION['id'] = $user_id;
  30. $_SESSION['nome'] = $nome;
  31. }else{
  32. if(!isset($query) || $query==="failed"){
  33. # Redirect user to error page
  34. header('Location: ' . $redireciona . '?failed');
  35.  
  36. }else{
  37.  
  38. if (strpos($link, 'failed') !== false) {
  39. header('Location: ' . $link);
  40. }else{
  41. header('Location: ' . $link . '&failed');
  42. }
  43. }
  44. }
  45.  
  46. }
  47. header('Location: ' . $redireciona);
  48.  
  49. }
  50. else {
  51. if (strpos($link, 'failed') !== false) {
  52. header('Location: ' . $link);
  53. }else{
  54. header('Location: ' . $link . '&failed');
  55. }
  56. }
  57. $stmt->close();
  58. }
  59. else
  60. {
  61.  
  62. }
  63. $ligadb->close();
Add Comment
Please, Sign In to add comment