0

i have an issue in logout function. my form data is not cleared when I submit my details in post method.

my form like this..

<form class=" validate-form" method="post" action="<?php echo base_url().'welcome/event/'; ?>">
<input class="input100" type="text" name="username" placeholder="username or email">
<input class="input100" type="password" name="pass" placeholder="password">

my controller like this..

public function events()
    {   

        $userid=$this->input->post('username');
        $passwrd=$this->input->post('pass');
        $this->load->helper(array('form', 'url'));
        $this->load->library('form_validation');
        $this->form_validation->set_rules('username', 'Username', 'required');
        $this->form_validation->set_rules('pass', 'Password', 'required');
        if($this->form_validation->run() === FALSE){
            $this->logout();  
        }
        else
        {
         $data=$this->login_model->login_valid($userid,$passwrd);    
        $this->session->set_userdata('user_details',$data[0]);
        $user_data = $this->session->all_userdata();    
        $sess_idUser= $user_data['user_details']->ID_USER;        
        if(isset($user_data['user_details']->lastname))
        {              
        $this->load->view('header');
        $this->load->view('events_page'); 

        }
        else
        {
        $this->session->sess_destroy();
        $this->logout();                                
        }

        }

    }

when i clear the session in this function not clear the form data.

 $userid=$this->input->post('username');
        $passwrd=$this->input->post('pass');

still post values not clear after submit the form.

I got an error Confirm Form Resubmission when I click back button, if I refresh this error page get back to this events(). because

$userid=$this->input->post('username');
            $passwrd=$this->input->post('pass'); is not cleared after form submission.

anyone tell me how to fix it?

Sridhar kumar
  • 17
  • 1
  • 1
  • 10

1 Answers1

1

Use redirect function , after successful submission of form the page should be redirected , also unset the data if stored in the session. On success use this ;

    redirect('your_page');
    $this->session->unset_userdata('any');
Meiji
  • 107
  • 1
  • 11