• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
should i use redirect or view if validation error exists?

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,

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.

hi PhilTem

maybe i will going to use this step,

if registration is failed because of validation error

i will use
to reduce redirect

and if registration successful

i will use redirect,
because if i use
if user refresh the page the post will repeat and the registration
will result to validation error and it will confuse the user.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.