daydreamer Posted March 25, 2009 Share Posted March 25, 2009 my page includes my function file like this: include 'process.php'; //after form submit process(); In process.php is this: function processdata(){ //put into db etc } function process(){ if($timerexceed){header("Location: index.php");} processdata(); } For some reason my header() line is not working, it wont redirect to index, and will processdata() even if $timerexceed is true. Why is this? (this is a simplified example of my situation). Thanks. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted March 25, 2009 Share Posted March 25, 2009 Code code code code code!!! (this is a simplified example of my situation) Without looking at the ACTUAL code we can't do anything. It could be a million reasons why it isn't working. Quote Link to comment Share on other sites More sharing options...
daydreamer Posted March 25, 2009 Author Share Posted March 25, 2009 yeh there is way too much code to post! but i think ive fixed it: <?php function process(){ if($timerexceed){header("Location: index.php"); } else { processdata(); } } ?> For some reason without the else there it will not redirect, maybe the header function will only redirect once the current function has reached its closing bracket. Weird. Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted March 25, 2009 Share Posted March 25, 2009 function process(){ if ($timerexceed) { header("Location: index.php"); exit; } else { processdata(); } } $timerexceed isn't set anywhere for your if test Simply setting the header to redirect won't actually execute the redirect until the script sends that information back to the browser, i.e. after it has finished any othe rprocessing within the script, unless you force it with an exit or a flush Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.