Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. $auth = $_COOKIE['authorization'];
  2. header ("Cache-Control:no-cache");
  3. if($auth !== "ok") {
  4. header ("Location:index.php");
  5. exit();
  6. }
  7.  
  8. <?php
  9.  
  10. error_reporting(0);
  11.  
  12. session_start();
  13.  
  14.  
  15. include("database.php");
  16. if(isset($_POST['login_button']))
  17. {
  18.  
  19. $userName = mysqli_real_escape_string($con, $_POST['username']);
  20. $userPass = mysqli_real_escape_string($con, $_POST['password']);
  21.  
  22. $hashedPass = hash('whirlpool', $userPass);
  23.  
  24. $query = mysqli_query($con, "SELECT Ime, Lozinka, Confirmed FROM `Igraci` WHERE `Ime` = '$userName' AND `Lozinka` = '$hashedPass' AND `Confirmed` = '1'") or die(mysqli_error());
  25. $row = mysqli_num_rows($query);
  26.  
  27. if($row > 0)
  28. {
  29. setcookie("username", $_POST['username'], time()+3600*24);
  30. setcookie("authorization","ok");
  31. header( "Location:welcome.php");
  32. exit();
  33. }
  34. else
  35. {
  36. echo '
  37.  
  38.  
  39. </br><div class="flash_error">Podatci koje ste uneli nisu ispravni, ili vas racun nije aktiviran.</div>
  40.  
  41. ';
  42.  
  43.  
  44. }
  45. }
  46.  
  47. if(isset($_GET['logout']))
  48. {
  49. setcookie("username", "", time()-60);
  50. setcookie("authorization","");
  51. header( "Location:index.php");
  52. exit(); # stop executing here
  53. }
  54.  
  55. if($_COOKIE['authorization'] == "ok")
  56. {
  57. header ("Location:welcome.php");
  58. exit();
  59. }
  60.  
  61. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement