Welcome Guest, Not a member yet? Register   Sign In
Validation errors not showing
#1

[eluser]fandelost[/eluser]
Hi, I'm using the Validation class from CI 1.7, everything's working fine on the production site, but on the online version, it won't show any error messages.

The routes are fine and I can log into the script if I provide the right credentials. I tried changing the uri_protocol values in the config file with no success.

I don't post the script because it's a pretty simple one, but I will if needed.
Has anyone stumbled upon a similar problem? Any ideas? I just don't know where to start looking for the error. Thanks!

EDIT: I've realized the online version won't let me login at all (using the right credentials) and it definitely doesn't pass $this->validation->run()
#2

[eluser]chmod[/eluser]
would you please post your code?
#3

[eluser]fandelost[/eluser]
Sure,

Code:
function ingresar()
{
    if ($this->redux_auth->logged_in())
    {
        go_home();
    }
    
    global $destination;
    
    $rules['email'] = 'required';
    $rules['password'] = 'required';
    
    $this->validation->set_rules($rules);
    
    $fields['email'] = $this->lang->line('email');
    $fields['password'] = $this->lang->line('password');
    
    $this->validation->set_fields($fields);
    
    if ($this->validation->run() == TRUE)
    {
        $this->_login($this->input->post('email'), $this->input->post('password'));
    }
    else
    {
        $this->parser->parse('login', $destination);
    }
}

As you can see, I'm also using the redux_auth library. The function go_home() it's just a custom helper using CI redirect() and _login() actually validates the input against the db using the correspondent "users" Model.

The "login" View contains the form that POSTs to this function ('ingresar' routing to 'main/ingresar'), and a custom extended Parser library adds top and bottom Views, including $CI->validation->error_string (after $CI =& get_instance() of course).

As I said, this works flawlessly in the local version but it just doesn't show the error messages online.
#4

[eluser]fandelost[/eluser]
I've realized the online version won't let me login at all (using the right credentials) and it definitely doesn't pass $this->validation->run()
#5

[eluser]fandelost[/eluser]
Wow! I think I finally solved this one, but it's a really odd solution.

First of all, after some testing, I found that the values from the form where not even POSTed to the Controller (at least not accesible with $this->input->post()), but if I created a new function and target my forms to it, the values would show up.

So I changed the Route from
Code:
$route['ingresar'] = "main/ingresar";
to
Code:
$route['do_ingresar'] = "main/ingresar";

..then I did the corresponding change in the View, from
Code:
echo form_open('ingresar');
to
Code:
echo form_open('do_ingresar');

That's it! However if I change 'do_ingresar' to some other values, It *might* go back to the original issue, like with 'iniciar_sesion' or 'inicio', but not with other words like 'asd' or 'testing'. Know how do you explain that language-nazi (kidding) uri routing?

I checked for the troublesome names to be duplicated somewhere, but no. Really creepy, I don't even know if this is a bug in CI or what, I checked it on several browsers and machines (in case it had to do with the cache of redirects) but it's the same in all.




Theme © iAndrew 2016 - Forum software by © MyBB