Welcome Guest, Not a member yet? Register   Sign In
What is the best way to echo out error messages from the Controller to the View
#1

[eluser]Namsu[/eluser]
I have a login script which authenticates credentials against the DB. I am quite new CI but not to PHP. I want to output my code in the view file above the form. I have found that I can use a class variable and call it using $this->varname or use flashdata through sessions. In your experience, what advice can you give for someone like me who has data passing through from the controller to the view with the least code possible. Bearing in mind I have tried the guide method:

-------------------------------------
$data = array(
'title' => 'My Title',
'heading' => 'My Heading',
'message' => 'My Message'
);

$this->load->view('blogview', $data);

-------------------------------------

Problem with the load->view code is that in the view I cannot define a variable in the conditional if it hasn't been established, as I am checking to see if it is == 1. My $data array is only being initialized and is only being called on an else statement in the controller. For example:

1)User submits forms (fields are not blank)
2)CI validates and checks against the database
3)CODE: if {credentials match = redirect}
else { dynamic data for view }


Messages In This Thread
What is the best way to echo out error messages from the Controller to the View - by El Forum - 07-28-2010, 05:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB