Advertisement
Guest User

Untitled

a guest
Apr 20th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. <?php
  2. include 'WebsiteUser.php';
  3. session_start();
  4.  
  5. if(isset($_SESSION['websiteUser'])){
  6.  
  7. if(!$_SESSION['websiteUser']->isAuthenticated()){
  8. header('Location:login.php');
  9. }
  10. }else{
  11. header('Location:login.php');
  12. }
  13.  
  14. $missingFields = false;
  15.  
  16. if(isset($_POST['submit'])){
  17. if(isset($_POST['username']) && isset($_POST['password'])){
  18. if($_POST['username'] == "" || $_POST['password'] == ""){
  19. $missingFields = true;
  20. } else {
  21. //All fields set, fields have a value
  22. $websiteUser = new WebsiteUser();
  23. if(!$websiteUser->hasDbError()){
  24. $username = mysqli_real_escape_string(stripslashes(strip_tags($_POST['username'])));
  25. $password = mysqli_real_escape_string(stripslashes(strip_tags($_POST['password'])));
  26. $websiteUser->authenticate($username, $password);
  27. if($websiteUser->isAuthenticated()){
  28. echo "this worked";
  29. $_SESSION['websiteUser'] = $websiteUser;
  30. header('Location:internal.php');
  31. }
  32. }
  33. }
  34. }
  35. }
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement