Welcome Guest, Not a member yet? Register   Sign In
should i use redirect or view if validation error exists?
#1

[eluser]Unknown[/eluser]
i have function called register() where it load the view of my registration form,
and the form action is to go to add() function,

inside add() function there's an input validation.
and if there a validation error or message
i redirect it to my register function,

the question is, should i redirect it to register function
or should i use the load->view() to show the form together
with the error message?

i am so confuse ,
please help,
thanks
#2

[eluser]PhilTem[/eluser]
Did you use the redirect approach and look at the result? It will not work since the form-validation errors are flash-messages resulting in them being deleted after one request. If you do a redirect you will basically add a second request (submitting the form is request number one) to your request chain thus losing all form-validation errors.
#3

[eluser]Unknown[/eluser]
hi PhilTem

maybe i will going to use this step,

if registration is failed because of validation error

i will use
Code:
$this->load->view()
to reduce redirect

and if registration successful

i will use redirect,
because if i use
Code:
$this->load->view()
if user refresh the page the post will repeat and the registration
will result to validation error and it will confuse the user.




Theme © iAndrew 2016 - Forum software by © MyBB