Close Sidebar

Page Redirection After Password Change is Successful

0 votes

I want to make a password-change-page redirect to another view after the password change is successful. However, I used the redirect helper method inside a function as indicted below. It redirects even before the password is changed. Kindly asisst. 

   public function security($status=''){
        $data['title'] = "Security Settings";
        $data['status'] = $status;
        $data['user'] = $this->profile_model->get_user($this->user->user_id);
        $data['bcrumb'] = link_breadcrumb(array(array('Home','home'),array('Profile','profile/view/'.$this->user->user_id),
            array('Security Settings','')));
$this->template->load(2, 'profile/security', $data, '', '');
redirect(site_url('institution/index')); //additional helper method to redirect page after password change
asked May 31, 2014 by wurohausa (20 points)

1 Answer

0 votes

A quick scan through the method'* body:

Lines 1-4: Sets data array'* values.

Line 5: Loads templated View with the data array.

Line 6: Redirects to another page.

I don't seem to see where password change is implemented. Left something out?

answered Jun 1, 2014 by ugochimbo (860 points)
This is the implementation of the password. It was an oversight.

public function security_settings(){
        $pass = $this->input->post('password', TRUE);
        $cpass = $this->input->post('cpassword', TRUE);
        $user_id = $this->user->user_id;

        if($pass==='' || $cpass==='')
            echo '{"msg":"alert alert-danger","html":"Passwords do not match"}';

            echo '{"msg":"alert alert-danger","html":"Passwords do not match"}';

        $hash = $this->phpass->hash($pass);
        while(strlen($hash) < 20){
            $hash = $this->phpass->hash($pass);

        if($this->profile_model->change_password($user_id, $hash))
            echo '{"msg":"alert alert-info","html":"Changes have been saved successfully"}';
            echo '{"msg":"alert alert-danger","html":"<b>Error!</b> Unable to save changes"}';
Yea, where was it (security_settings()) called?.. it doesnt appear to have been invoked from the security($arg) method in the question... thats why the password isn't changed before the re-direct.
  1. Login or Register

    Click to open login box. Login or register from here

  2. Search Box

    Click to open the search box. You can search within the site content here

  3. Hello Admin!

    You can reach to admin section by clicking on this navigation item

  4. Ask A Question

    Start asking a question by clicking on this navigation item

  5. Find All Recent Activities

    Here you can find all recent activities recent question, answer, comment etc

  6. Vote Question or Answer

    You can give up or down vote to the question or answer by clicking on respective arrow button

  7. Give Your Answer

    Click this button to give your answer to the question

  8. Add Comment

    To post comment click on the button

  9. Select Best Answer

    Consider the answer as the best answer for your question by clicking one to the tick

  10. Congratulations!!!

    Now you learn how to use site. Why don't you start to ask a question or provide some answer to the community!