I have simple login in zf2. I want to show error message error to user when username/password didn't match.
In view/login.php:
if (isset($error_msg))
{
echo $error_msg;
}
In Controller I have:
$msg = array('error_msg' => 'Invalid Username or Password');
return $this->redirect()->toRoute('login', $msg);
Here error_msg cannot passed to view, what are wrong with this?
Furthermore I also try
$model = new ViewModel(array(
'error_msg' => 'Wrong username or password',
));
$model->setTemplate('login/index');
return $model;
But here link didn't go to login/index. but instead go to login/process. Process is the action in which login is processed.
Help me friends please. I want to pass error message from controller to view . So how should I do it.