0

i have this controller(visits.php) that use 3 models to build page, then it pass 4 vars to a view.

this view contain a form that submit to another page (add_user.php)

my question is how can i send the user back to visits.php in case the for_validation is false ? do i have to reload visits.php allover again ?-waste of resourss- or i should just send him back in history with js or php header for example ? can u plz show me an example of how u best handle false result of form_validation ?

Note that when i user

header('Location: ' . $_SERVER['HTTP_REFERER']);

i couldnt echo validation_error() :(

thanks for help

1 Answer 1

3

You can store validation_error() in a piece of flash data, then you can use header(Location) - or you could use the codeigniter redirect() function and fetch the flashdata in the redirected page.

Sign up to request clarification or add additional context in comments.

1 Comment

Codeigniter has this functionality built in, why would you load the errors into flashdata and use header to redirect, makes no sense and isn't saving any resources over reloading the page in the controller.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.