Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. class UserService
  2. {
  3. protected $_email; // using protected so they can be accessed
  4. protected $_password; // and overidden if necessary
  5. protected $_user; // stores the user data
  6.  
  7. public function __construct($email, $password)
  8. {
  9. $this->_email = $email;
  10. $this->_password = $password;
  11. }
  12. public function login()
  13. {
  14. $user = $this->_checkCredentials();
  15. if ($user) {
  16. $this->_user = $user; // store it so it can be accessed later
  17. $_SESSION['user_id'] = $user['id'];
  18. return $user['id'];
  19. }
  20. return false;
  21. }
  22.  
  23. protected function _checkCredentials()
  24. {
  25.  
  26. /* Faz a rotina para verificar se o usuário está no banco de dados*/
  27. /* e se a senha confere */
  28.  
  29. /* Se OK retorna os dados do usuário, se não, retorna false */
  30.  
  31. }
  32. }
  33.  
  34. session_start();
  35. include("class.user.php");
  36.  
  37. $user = new UserService($_POST['email'], $_POST['pass']);
  38.  
  39. public function getUserName($uID)
  40. {
  41. /* Verifica se o usuário está logado e busca o nome no DB */
  42. }
  43.  
  44. session_start();
  45. include("class.user.php");
  46.  
  47. $user = new UserService();
  48.  
  49. $userName = $user->getUserName($_SESSION['user_id']);
  50.  
  51. echo $userName;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement