Welcome Guest, Not a member yet? Register   Sign In
Redirect Problem
#1

[eluser]Computerzworld[/eluser]
Hello. I am having problem in redirecting the page to other page. Here is the code which I have written.

Code:
function forgotPass()
    {
        $this->pageHeader();
        
        $rules = array(
                    "email_address"    =>    "required|valid_email|callback_email_check",
                    );
        $this->validation->set_rules($rules);
        
        $fields = array(
        "email_address"        =>    "E-mail",
        );
        $this->validation->set_fields($fields);
        
        if ($this->validation->run())
        {
            $email = $this->input->post('email_address');
            //$this->mdl_users->userName = $userName;
            redirect('login/checkUser/'); /*This is not working */
        }
        
        $data = array(
        "TITLE"          => $this->lang->line('TITLE'),
        "EMAIL"       => $this->lang->line('EMAIL'),
        "SUBMIT"       => $this->lang->line('SUBMIT')
        );
        
        $this->parser->parse('forgotpass',$data);
        $this->pageFooter();
    
    }
    
    function checkUser()
    {
        $this->pageHeader();
        echo "here";
        exit;
        $this->pageFooter();
    
    }

Instead of redirecting the page it remains in the same function(forgotPass). I am stuck at this point. Please help me. Thanks in advance.
#2

[eluser]Computerzworld[/eluser]
I even tried with header() tag but it didn't worked Sad
#3

[eluser]gtech[/eluser]
first of all check that you are actually getting in the condition
Code:
if ($this->validation->run())
        {
          // take this out after test or redirect will not work
          echo "Hello Im in this condition";
          //redirect('login/checkUser/');
        }

then I think that the redirect function requires no content to be sent to the browser or a header already sent message will be generated so try and move the page header call to the bottom of the function AFTER the redirect, see if that works.

Code:
...
        $this->pageHeader();
        $this->parser->parse('forgotpass',$data);
        $this->pageFooter();
    
    }
#4

[eluser]Computerzworld[/eluser]
yup that works perfectly....
i just moved $this->pageHeader() from top to bottom so no data is sent along with header and it worked....
thanks very much....
#5

[eluser]gtech[/eluser]
no probs, glad it worked.




Theme © iAndrew 2016 - Forum software by © MyBB