Welcome Guest, Not a member yet? Register   Sign In
[HELP]flashdata returning different data
#1

[eluser]geocine[/eluser]
i have this code snippet on my page controller

Code:
function edit( $id = '')
    {
        $this->load->library('session');
        $this->load->library('form_validation');
        switch ( $_SERVER ['REQUEST_METHOD'] )
        {
    
            case 'GET':
                
                $this->session->set_flashdata( 'id', $id );        
    
            break;
    
            case 'POST':
                
                $this->form_validation->set_rules( 'page_Category', lang('page_Category'), 'required' );

                if ( $this->form_validation->run() == FALSE )
                {

                    $this->session->keep_flashdata('id');
                    $data['values']['page_Category'] = set_value( 'page_Category' );
                    $data['form_mode'] = 'edit';
                    $this->load->view( 'edit_ezloadinc_page.php', $data );
                }
                elseif ( $this->form_validation->run() == TRUE )  
                {
                    $data_post['page_Category'] = $this->input->post( 'page_Category' );
                    $id = $this->session->flashdata('id');
                    redirect( 'page/info/' . $id );  
                }
    
    
            break;
            
    
            default:
            break;
        }

                
    }

if I would be editing an entry using page/edit/1, 1 should be stored on flashdata since its a GET request. Once the user submits the form after editing it will be going to page/edit and through the POST request it will then be redirected to page/info/<the id that was stored on the flashdata>.

The weird thing that happens is when $id = $this->session->flashdata('id'); is called. The returned value to id is "css"

I tried using userdata but the same thing happens. What seems to be the problem?
#2

[eluser]Jondolar[/eluser]
How are you creating the variable $id that is being passed to the edit() function?

However the problem gets fixed, why don't you put a hidden field on your form page that holds the ID? Then, when you post back to the edit() function, just take the value of the posted id field.
#3

[eluser]geocine[/eluser]
This method works on my other controllers except my page controller.




Theme © iAndrew 2016 - Forum software by © MyBB