Welcome Guest, Not a member yet? Register   Sign In
Help form validation
#1

[eluser]Unknown[/eluser]
Quote: public function index(){
$this->load->library("form_validation");
$this->form_validation->set_rules("login", "Login", "callback_check");

if($this->form_validation->run() == FALSE)
{
$this->load->view("login/login_view");
}
else
{
//I want access to $data['info'] that return from check() function

}
}
public function check(){
$data['info'] = array(
"username" => $this->input->post("username"),
"password" => $this->input->post("password"),
);
$data['info'] = $this->User_model->checklogin($data['info']);
if($data['info'] == FALSE)
{
$this->form_validation->set_message("check", "Wrong username or password. %s fail.");
return FALSE;
}
else
{
return $data['info']; //$data['info'] is array
}
}

In index() function, How can i access to $data['info'] that return from check() function.

Please help me. Thanks all!
#2

[eluser]Giorgio Nordo[/eluser]
You could define a property info inside the class and then accessing to it in every point by $this->info.
#3

[eluser]Unknown[/eluser]
Thanks for your answer!

In Code Igniter Guide - Form Validation write:

"You can also process the form data that is passed to your callback and return it. If your callback returns anything other than a boolean TRUE/FALSE it is assumed that the data is your newly processed form data."

In my case, check() function return an array (not boolean). Well, What is the variable that check() function returns value to? If i don't define property info inside class, i access it over what variable.




Theme © iAndrew 2016 - Forum software by © MyBB