CodeIgniter Forums
When I refresh a page it sends the same data - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: When I refresh a page it sends the same data (/showthread.php?tid=34781)



When I refresh a page it sends the same data - El Forum - 10-09-2010

[eluser]shinokada[/eluser]
I have a following controller, model and view.

When I refresh a page it sends the same data again.

What am I doing wrong here?

Thanks in advance.

Code:
//Controller

   function Welcome()
    {
        parent::Controller();
                $this->load->helper('url');
                $this->load->database();
    }

   function forms(){
            $data['header']='input form';
            $data['title']='input form';
            $this->load->model('MForm');
            if ($this->input->post('start_time')){
               $this->MForm->enterform();
                redirect('welcome/forms', 'refresh');
             }else{
                $this->load->view('forms',$data);
            }            
        }

// model

function enterform(){

        $data = array(
            'date' => $this->input->post('date'),
            'start_time' => $this->input->post('start_time'),
            'finish_time' => $this->input->post('finish_time'),
            'instructor' => $this->input->post('instructor'),
        );
        $this->db->insert('schedules',$data);
     }


// view

<form name="form1" method="post" action="forms">
    <!-- form 1 -->
<label for='start_time'>1. Start Time</label>
&lt;input type="text" name="start_time" /&gt;
<label for='finish_time'>Finish Time</label>
&lt;input type="text" name="finish_time" /&gt;
<label for='instructor'>Instructor</label>
<select name="instructor">
<option value="john">John</option>
<option value="mary">Mary</option>
<option value="jim">Jim</option>
</select>
&lt;input type="hidden" name="date" value="&lt;?php echo $date; ?&gt;"/&gt;
&lt;input type="submit" name="submit" value="Submit" /&gt;
&lt;/form&gt;



When I refresh a page it sends the same data - El Forum - 10-09-2010

[eluser]Twisted1919[/eluser]
Everythinbg seems fine, except maybe 2 things :
1) try : redirect('welcome/forms');exit();
2) your form is vulnerable to xss attacks Wink try :
Code:
$data = array(
            'date' => $this->input->post('date',TRUE),
            'start_time' => $this->input->post('start_time',TRUE),
            'finish_time' => $this->input->post('finish_time',TRUE),
            'instructor' => $this->input->post('instructor',TRUE),
        );



When I refresh a page it sends the same data - El Forum - 10-09-2010

[eluser]shinokada[/eluser]
Thanks for your reply and tips.

However it still re-send when I refresh or F5.


When I refresh a page it sends the same data - El Forum - 10-09-2010

[eluser]shinokada[/eluser]
I noticed that it happens with FF but not Chrome.

I am using Ubuntu.

Any idea?


When I refresh a page it sends the same data - El Forum - 10-09-2010

[eluser]InsiteFX[/eluser]
Maybe the browser is caching the page!

InsiteFX