For example, a login method is used to output the login view {code...}. At this time, the login page is indexlogin. Then, submit the form data to the login_check () method {code ...} $ this-& amp; gt; form_validation-& amp; gt; run () Form Verification Failed, output again l... for example, a login method is used to output the login view.
public function login(){ $this->load->view('login');}
At this time, the login page is
index/login
. Then, submit the form data
login_check()
Method
public function login_check(){ $this->form_validation->set_rules('email', 'email', 'trim|required|valid_email'); $this->form_validation->set_rules('password', 'password', 'trim|required'); if ($this->form_validation->run() === true) { //..... }else{ $this->load->view('login'); }}
$this->form_validation->run()
Form Verification Failed. the login view is output again and an error is displayed. At this time, the login page address
index/login_check
. This is so bad that you do not want the link address to change. In addition
login()
And
login_check()
In addition to the implementation of merge processing, is there any better solution? Thank you for your advice.
Reply content: for example, a login method is used to output the login view.
public function login(){ $this->load->view('login');}
At this time, the login page is
index/login
. Then, submit the form data
login_check()
Method
public function login_check(){ $this->form_validation->set_rules('email', 'email', 'trim|required|valid_email'); $this->form_validation->set_rules('password', 'password', 'trim|required'); if ($this->form_validation->run() === true) { //..... }else{ $this->load->view('login'); }}
$this->form_validation->run()
Form Verification Failed. the login view is output again and an error is displayed. At this time, the login page address
index/login_check
. This is so bad that you do not want the link address to change. In addition
login()
And
login_check()
In addition to the implementation of merge processing, is there any better solution? Thank you for your advice.
You can submit the form using ajax. This will not cause the page to jump to login_check.
Jump to if verification failslogin?error=err_code
Use in CIredirect('index/login')
This function is redirected.
In yourelse
Used in
To solve this problem elegantly, you need to use routes,
Judgmenthttp
Ing the verb to the corresponding method.