0
votes

So I am using session to hold username and then check if its there. if yes, then use it to update related to current transaction. The following is my code:

public function update_edit()
    {
            /* echo " //// INSIDE UPDATE EDIT "; */

             $this->form_validation->set_rules('fullname', 'الاسم الكامل', 'isset|required|min_length[6]|max_length[100]');
                //echo 'Username: ';
                //check that there are no form validation errors
                if($this->form_validation->run() == FALSE)
                {   
                     echo " //// INSIDE FORM VALIDATION"; 
                    if(($this->session->userdata('username')!=""))
                    {
                                             echo " //// INSIDE SESSION VALIDATION"; 
                        $data = array();
                        $session_user = $this->session->userdata('username');
                        if(isset($session_user) && $session_user != '' && $session_user != null)
                        {

                            $data = $this->profileModel->load_user_editable_data($session_user);
                            $this->load->view('layout/header');
                            $this->load->view('profile_edit', $data);
                            $this->load->view('layout/footer');
                        }else{
                            $this->error_page();
                        }

                    }else{
                        //$this->load->view('login');
                        $this->login();
                    }
                }else{
                    echo "dasdaskhdkjashjdas";
                    $session_user = $this->session->userdata('username');
                    echo "Session User: " . $session_user;
                    if(isset($session_user) && $session_user != '' && $session_user != null)
                    {
                        echo "going to update;";
                        $complete = $this->profileModel->update_profile($session_user); 
                        echo "<br>finished updating...";
                        if($complete == 1)
                        {       
                            echo "Complete  = " . $complete;
                            $this->load->view('layout/header');
                            $this->load->view('update_complete');
                            $this->load->view('layout/footer');
                        }elseif($complete == 2){
                            echo "Complete  = " . $complete;

                            $this->error_page();
                        }

                    }
                }

    }

The problem here is that after echo dasdaskhdkjashjdas, nothing the session check doesn't work. I printed the value and it is empty. How can this be when in the function before it worked well and loaded the data? This function is supposed to check the loaded data changed or not, then submit that new data.

Please help :)

1

1 Answers

0
votes

Change this:

if(isset($session_user) && $session_user != '' && $session_user != null)

to this:

if(!empty($session_user))