0

I am trying to do a register form with CodeIgniter. My form is somewhere in the middle of my page and it has an anchor attached.

I want the page to load to that anchor in case the sent form failed, so I am using redirect(myweb#register) but the form errors are lost in the proccess, when they should be displayed after making the attempt to send this form.

What can I do?

kpagcha
  • 174
  • 2
  • 2
  • 9

2 Answers2

2

If you are doing a redirect the one way of keeping the errors is to use flash data: http://ellislab.com/codeigniter%20/user-guide/libraries/sessions.html

$this->session->set_flashdata('error', 'message');
redirect(myweb#register);
gelviis
  • 448
  • 1
  • 4
  • 19
0

Rather than redirecting, you should let the page display as usual so your error display, then use something like jQuery ScrollTo to go back to the anchor.

Jessica
  • 7,075
  • 28
  • 39
  • Did you see this: http://stackoverflow.com/questions/11031596/how-to-show-validation-errors-using-redirect-in-codeigniter – Jessica Dec 15 '13 at 21:18
  • Actually I did, but I can't redirect to index because the form is processed in a different controller. I don't know how to call a controller from another. – kpagcha Dec 15 '13 at 21:22
  • Then that is the real problem. Which page you redirect to is irrelevant. – Jessica Dec 15 '13 at 21:23
  • I don't understand what you're trying to say with that. – kpagcha Dec 15 '13 at 21:25