Currently, i'm working with MVC pattern applied in PHP language. Please anyone help to define logic for login controller. Here is the code that i have done.
public function login($name = '') {
//do logic check and change template of model
// or redirect to dashboard
if(isset($_GET['uname'])) {
if(empty($_GET['uname']) || empty($_GET['pwd'])) {
$this->model->template = 'user/login.php';
$this->model->data = array('content' => 'You login information is not complete ', 'link' => 'home');
$this->view->render();
} else {
$data = array('uname' => $_GET['uname'], 'pwd' => $_GET['pwd'] );
if($this->model->login($data) != 0) {
Session::setSession('uname',$_GET['uname']);
Session::setSession('loggedIn', true);
header("Location: /eversoft/public/home");
} else {
$this->model->template = 'user/login.php';
$this->model->data = array('content' => 'You login information is not correct ', 'link' => 'home');
$this->view->render();
}
}
} else {
$this->model->template = 'user/login.php';
$this->model->data = array('content' => 'Hello from login', 'link' => 'home');
$this->view->render();
}
$this->model->template = 'user/login.php';
$this->model->data = array('content' => 'Hello from login', 'link' => 'home');
$this->view->render();
}
Aucun commentaire:
Enregistrer un commentaire