CodeIgniter Forums
avoid resend data when click on refresh menu - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: avoid resend data when click on refresh menu (/thread-22169.html)



avoid resend data when click on refresh menu - El Forum - 08-31-2009

[eluser]ranjitbd[/eluser]
Code:
//how to avoid sending data into database when click on refresh button.
//i already set validation.so no one can submit any empty feedback.but when a feed back //is submitted and show the session message to the
//user that feedback submitted successfully.then if i click on refresh in the browser it //submitted again.
//i can redirect to another page to avoid this.but i want to stay in the same feed back //page..

//here is my code

  function feedback()
  {  
      $data = array();
      $data[‘mainContent’] = $this->load->view(‘tmbd/feedback’, $data, true);
      $this->load->view(‘index’, $data);
  }

  function feedbackSave()
  {
      $data=array();
    
      $data[‘subject’] = $this->input->post(‘subject’, true);
      $data[‘name’] = $this->input->post(‘lname’, true);
      $data[‘address’] = $this->input->post(‘address’, true);
      $data[‘email’] = $this->input->post(‘email’, true);
      $data[‘mobile’] = $this->input->post(‘mobile’, true);
      $data[‘comments’] = $this->input->post(‘comments’, true);
    
      $datetime = date(‘Y-m-d H:i:s’);
      $data[‘date’] = $dateTime;

      $this->load->model($this->config->item(‘generalModel’), ‘save_feedback’,TRUE);
      $this->save_feedback->feedbackSave($data);
    
      $this->session->set_flashdata(‘feedback’, ‘Feedback send successfully’);
      $this->feedback();
  }
// i cant go to another page.i have to show that feedback page to user even after submit feed back just with a flash message.
//maybe it can be solved by using headers function to reload the page….but i dnt knw how to use it?



avoid resend data when click on refresh menu - El Forum - 09-01-2009

[eluser]pistolPete[/eluser]
You already posted here the same question: http://ellislab.com/forums/viewthread/127492/

And it was already answered, you have to do a redirect do clean the POST data.