php redirect after page load

Permabanned
Joined
25 Oct 2004
Posts
9,078
Hi folks,

How would i go about redirecting a page in php after the page has loaded ?

Basically i have a page which checks to see if a user has filled in a form if they havent it redirects them to the start of the form but header() wont work as the page has already loaded.

Any ideas ?
 
do all your form validation before sending anything to the screen.

PHP:
if($_POST) {
   //check form
   //if good use header location to re-direct page
}
<html>
//form goes here
</html>
 
well you can use this line at the top of the script.

ob_start()

that should work i think. but i still don't get how you can't validate form data without displaying anything though. :p
 
Doesn't seem the best way of doing things.. And it'll make the page pretty useless as it will flash up for half a second and then reload another page.
 
Back
Top Bottom