Welcome Guest, Not a member yet? Register   Sign In
Form validator
#1

[eluser]Watnow[/eluser]
Hello,

I'm new to codeigniter, but i like it very much. building @ the moment an logon system i have an profile page where the user can change his name/username/email address etc.

now i have an question i want to use the form validator of CI i want to know can i use double variable for the callback function like:


Code:
function changeprofile(){

$this->form_validation->set_rules('email', 'email', 'callback_email_check');

}
function email_check($oldstr,$newstr){
//oldstr = the old email adres from an database query.
//newstr = new email adres that is not in database.
if($oldstr == $newstr){

return True;

}else{

//do something else like checking if the email is avaible ?

}


}

is this possible?

Please let me know..

Greet,
David
#2

[eluser]WanWizard[/eluser]
You can't do it that way, but you can do
Code:
$old_email = '[email protected]';
$this->form_validation->set_rules('email', 'email', 'callback_email_check['.$old_email.']');

So you have to retrieve the old address up front, and pass it to the callback for validation.
#3

[eluser]Watnow[/eluser]
Okee thanks i'm gonna try that.




Theme © iAndrew 2016 - Forum software by © MyBB