Welcome Guest, Not a member yet? Register   Sign In
Recover data after validation
#1

[eluser]Neewouay[/eluser]
Hi,

I'm Swiss French, sorry for my english is very limited (thanks Google Translator^^), I will try to explain my problem.

I do not know how to recover my data after pass validation and preparing to send in a function that will look into a database if the data exist, if the data do not exist, the function returns an error that will will be displayed in <?php echo validation_errors(); ?>

How?

Thanks
#2

[eluser]Michael Wales[/eluser]
You'll need to use a Callback - these are documented in the User Guide.
#3

[eluser]Neewouay[/eluser]
Hi,

I tried to test it :

Code:
<?php
function connect()
{
    $this->form_validation->set_rules('email', 'E-amil', 'required|md5|callback__check');
    $this->form_validation->set_rules('password', 'Password', 'required|md5');
        
    if($this->form_validation->run() == FALSE)
    {
        echo'error';
    }
    else
    {
        echo'ok';
    }
}
    
function _check($email)
{    
    echo $email.'<br />'.$this->input->post('password');
}

email is in md5, but not the password...
How to get the password md5 ?

Thanks
#4

[eluser]Michael Wales[/eluser]
Switch the order of your set_rules.

Emails' set_rules runs, then calls the callback (which uses the password from the $_POST). After that, your Password's set_rules runs which is where it is finally MD5d.
#5

[eluser]Neewouay[/eluser]
Code:
&lt;?php
function connect()
{
    $this->form_validation->set_rules('email', 'E-amil', 'required|md5');
   $this->form_validation->set_rules('password','Password','required|md5|callback__check');
        
    if($this->form_validation->run() == FALSE)
    {
        echo'error';
    }
    else
    {
        echo'ok';
    }
}
    
function _check($password)
{    
    echo $password.'<br />'.$this->input->post('email');
}

Now is the email that is not in md5
I did not understand at all how it works ...
#6

[eluser]Neewouay[/eluser]
up ?




Theme © iAndrew 2016 - Forum software by © MyBB