CodeIgniter Forums
Input doesn't clear after each request? - 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: Input doesn't clear after each request? (/showthread.php?tid=32523)



Input doesn't clear after each request? - El Forum - 07-26-2010

[eluser]parham90[/eluser]
Hi,

I have started creating that session-based wizard I talked about earlier. It has gone great up to this point, but there is a problem:

I want the user's session data to be incremented when $this->input->post('submit') is present, meaning that the submit button has been pressed. This doesn't work. What I did to find it out was this:

1. I loaded the first page.
2. I clicked on next.
3. The second page loaded. I went to the address bar and pressed enter, causing the address to be requested again.
4. The third step came up, even though I hadn't clicked on submit at all.

Here is the function:

Code:
function signup()
{
if ($this->session->userdata('step'))
$step = $this->session->userdata('step');
else
{
$step = 1;
$this->session->set_userdata('step', 1);
}
if ($this->input->post('submit'))
{
$step = $step + 1;
$this->session->set_userdata('step', $step + 1);
}
if ($step == 1)
$this->load->helper('file');
$this->template->write('title', ': Sign Up');
$this->template->write_view('content', 'users/signup/' . $step . '.php');
$this->template->render();
}

Any ideas?

Thanks!