Welcome Guest, Not a member yet? Register   Sign In
Success message on form validation instead of error
#1

[eluser]coldfire82[/eluser]
Hi,

I want to display a "success" or "thankyou" message on return from form validation. How to do that. here is the callback function that I call after email validation

Code:
function subscriber_check($str)
    {
        $where='where  email="'.$str.'"';
        
        $res=$this->module->selects($where,'subscribers');
        if(!empty($res)){
            $this->validation->set_message('subscriber_check', 'You are already subscribed');
            return FALSE;
        }else{
            $this->validation->set_message('subscriber_check', 'Thankyou!');
            return TRUE;
        
        }
    }

quick response is much appreciated. BTW you guys are doing gr8!
#2

[eluser]danmontgomery[/eluser]
Code:
if( $this->form_validation->run() == true) {
    echo "Success";
} else {
    echo "Failure";
}
#3

[eluser]coldfire82[/eluser]
[quote author="noctrum" date="1265923892"]
Code:
if( $this->form_validation->run() == true) {
    echo "Success";
} else {
    echo "Failure";
}
[/quote]

No no. I meant for the View. because, we show only the errors in the validation err message in the view by using,

Code:
echo $this->validation->email_error;

I need to show some validation success message in the view. Lets say someone submits a email subscription form and on successful validation, it shows some success message. (I think thats not a CI thing. I hvae to use some JS hack)
#4

[eluser]Alex C.[/eluser]
Code:
echo (!empty($this->validation->error_string)) ? 'Done' : $this->validation->error_string ;
#5

[eluser]coldfire82[/eluser]
[quote author="Alex C." date="1265929977"]
Code:
echo (!empty($this->validation->error_string)) ? 'Done' : $this->validation->error_string ;
[/quote]

Yes, i am now using this same concept. thanks anyway.
#6

[eluser]Alex C.[/eluser]
by the way, it has to be empty and not !empty




Theme © iAndrew 2016 - Forum software by © MyBB