PHP User::get_by_login Examples

PHP User::get_by_login - 2 examples found. These are the top rated real world PHP examples of User::get_by_login extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
 public function signin()
 {
     switch ($_SERVER['REQUEST_METHOD']) {
         case 'GET':
             if (isset($_SESSION['user'])) {
                 show_message('message success', "You're already connected as " . $_SESSION['user']);
                 include 'views/home.php';
             } else {
                 include 'views/signin.php';
             }
             break;
         case 'POST':
             if (isset($_POST['login']) && isset($_POST['password'])) {
                 $u = User::get_by_login($_POST['login']);
                 if (!is_null($u)) {
                     if ($u->password() == sha1($_POST['password'])) {
                         $_SESSION['user'] = $u->login();
                         show_message('message success', "You're connected");
                         header('Location: ' . BASEURL . '/index.php');
                     } else {
                         show_message('message error', "Login or password false");
                         include 'views/signin.php';
                     }
                 } else {
                     show_message('message error', "Login or password false");
                     include 'views/signin.php';
                 }
             } else {
                 show_message('message error', "Incomplete data!");
                 include 'views/signin.php';
             }
             break;
     }
 }
Example #2
0
 public function show_diaries()
 {
     if (user_connected()) {
         $user = User::get_by_login($_SESSION['user']);
         $diaries = array();
         $diaries = Diary::get_all_diaries($user->id());
         include 'views/diaries.php';
     } else {
         show_message("message_error", "Vous n'ĂȘtes pas connectĂ©");
         include 'views/signin.php';
     }
 }