Unexpected Recursive Page in php Codeigniter form
23:43 09 Dec 2015

Whenever i click submit button within form with blank textfield, my browser url always go to new url that seems to be recursive, here's the form :

enter image description here

But if this form be clicked once more, it will be like this :

enter image description here

Below are my code :

Controller, form.php

load->helper(array('form', 'url'));
        $this->load->library('form_validation');
        $this->form_validation->set_rules('username', 'Username', 'required');
        $this->form_validation->set_rules('password', 'Password', 'required',
                array('required' => 'You must provide a %s.')
        );
        $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
        $this->form_validation->set_rules('email', 'Email', 'required');

        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('myform');
        }
        else
        {
            $this->load->view('formsuccess');
        }
    }

    public function validate()
    {
        /* I want to use this method, instead of index() */
        $this->load->helper(array('form', 'url'));
        $this->load->library('form_validation');
        $this->form_validation->set_rules('username', 'Username', 'required');
        $this->form_validation->set_rules('password', 'Password', 'required',
                array('required' => 'You must provide a %s.')
        );
        $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
        $this->form_validation->set_rules('email', 'Email', 'required');

        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('myform');
        }
        else
        {
            $this->load->view('formsuccess');
        }       
    }
}
?>

View, myform.php





My Form





Username
Password
Password Confirm
Email Address

I know, it will work fine if i use public function index() or in myform.php be like this :

But i want to use method validate() in my form. Any solution ? Thanks before...

php html codeigniter