Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. <?php
  2. require_once('header.php');
  3. require_once ('datasets/Login2.php');
  4. require_once ('datasets/UserDataSet.php');
  5. require_once ('classes/User.php');
  6.  
  7. $view = new stdClass();
  8. $view->pageTitle = 'login';
  9. $userDataSet = new UserDataSet();
  10.  
  11. //$inputEmail= $_POST['inputEmail'];
  12. //$inputPassword = $_POST['inputPassword'];
  13.  
  14. if (isset($_POST['login'])) {
  15. $user= new UserDataSet();
  16.  
  17.  
  18. // store login input in vairable
  19. // store password after encrypting using md5
  20.  
  21. $email = $_POST['email'];
  22. $ePassword = $_POST['password'];
  23.  
  24. // call check email.
  25. $result = $userDataSet->checkEmail($email);
  26.  
  27. if ($result == false){
  28. // if false, the email doesn't exist in the db
  29. echo 'Email or Password is incorrect';
  30. } else if ($result == true)
  31. {
  32. // else, call check password
  33. if ($userDataSet->checkPassword($email, $ePassword) == false){
  34. //incorrect password
  35. echo 'Email or Password is incorrect';
  36.  
  37. } else {
  38. //log in
  39. echo 'You are logged in.';
  40.  
  41. //makes user object, serializes to avoid enctype disruption
  42. $userInfo = new user($userDataSet->retrieveUserDetails($email));
  43. $_SESSION['user']=true;
  44. $_SESSION['userInfo'] = base64_encode(serialize($userInfo));// object to string
  45. //echo base64_encode(serialize($userInfo));
  46. echo $_SESSION['userInfo'];
  47.  
  48. $test = $_POST['email'];
  49. }
  50. }
  51.  
  52. }
  53. require_once("views/login.phtml");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement