0

Controller:

$data = array(
    'error_message' => 'Invalid Username or Password'
);
$this->load->view('/login/index', $data);

View page:

<?php echo $error_message; ?>
Emissary
  • 9,954
  • 8
  • 54
  • 65
  • 1
    possible duplicate of [Passing variable from controller to view in CodeIgniter](http://stackoverflow.com/questions/12294527/passing-variable-from-controller-to-view-in-codeigniter) – marian0 Mar 29 '15 at 10:05
  • Please elaborate the issue that you are facing. what is exactly expected? are you facing any errors? – Manish Kothari Mar 29 '15 at 11:14
  • Do you getting any error?like view not found.Also you can see https://ellislab.com/codeigniter/user-guide/general/views.html which will help you learn it – Shaiful Islam Mar 29 '15 at 13:46

1 Answers1

0

I guess you have put the view path wrong and hence the variable is not reaching the view.
This is how it should be,


Controller: (applications/controllers/filename.php)

$data = array(
    'error_message' => 'Invalid Username or Password'
);

$this->load->view('login/index', $data);   # removed slash here


View: (applications/views/login/index.php)

<?php echo $error_message; ?>
Parag Tyagi
  • 8,780
  • 3
  • 42
  • 47