public function indexAction() { $data['title'] = 'Đăng Nhập | Blog Tin Tức'; $data['menu'] = Menu::where('status', 1)->get(); if (isset($fullname)) { return $this->redirect('userinfo'); } if ($this->getPostData("action")) { $postData = $this->getPostData(); if (User::checkLogin($postData) != Null) { echo "<script>alert('Đăng nhập thành công !')</script>"; $dataget = User::checkLogin($postData); $name = $dataget['name']; $this->app['session']->set("fullname", $name); $fullname = $this->app['session']->get('fullname', 'Null'); return $this->redirect('userinfo', $dataget); } if (User::checkLogin($postData) == false) { echo "<script>alert('Đăng nhập thất bại !')</script>"; header("Refresh:0; url='/login.html'"); return $this->render('default/user/login.html.twig', $data); } exit; } return $this->render('default/user/login.html.twig', $data); }
public function loginAction() { $data = array(); if ($this->getPostData()) { $postData = $this->getPostData(); if ($user = User::checkLogin($postData['email'], $postData['password'])) { $this->app['session']->set("logged", $user); return $this->redirect('entrycontroller_index', array()); } else { $data['error'] = 'Login failed! Please try again!'; } } return $this->render('user/login.html.twig', $data); }
public function signupAction() { if ($this->getPostData()) { //co the dung them ham : isPostRequest() để kiểm tra cái hàm này tự viết $postData = $this->getPostData(); $t = User::checkLogin($postData['email']); if (count($t) <= 0) { $postD['password'] = md5($postData['password']); $postD['email'] = $postData['email']; User::insertNew($postD); return $this->redirect('loadlogin'); } $data['error_login'] = "******"; return $this->render('user/login.html.twig', $data); } }