TeddyKiller Posted March 21, 2010 Share Posted March 21, 2010 Is it possible to reload a page without using header("location: /"); As that generates an headers already sent error. (When using the script after any html) Quote Link to comment Share on other sites More sharing options...
oni-kun Posted March 21, 2010 Share Posted March 21, 2010 You can use the HTML Meta refresh method, but if you require to refresh the page using headers, Place ob_start at the beginning of your code. Although this is a fix than a solution, It is a valid one. Quote Link to comment Share on other sites More sharing options...
dreamwest Posted March 21, 2010 Share Posted March 21, 2010 echo "<script language=Javascript>document.location.href='http://site.com';</script>"; Quote Link to comment Share on other sites More sharing options...
Ruzzas Posted March 21, 2010 Share Posted March 21, 2010 or <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"> </script> <script type="text/javascript"> $(document).ready(function() { location.reload(); }); </script> Quote Link to comment Share on other sites More sharing options...
Andy-H Posted March 21, 2010 Share Posted March 21, 2010 Or you could simply re-think your code so the logical code can be processed before any output is given and use a Header('Location: ?');, JavaScript can be disabled easily, so I wouldn't rely on it. Meta refresh only occurs once the page has loaded so if it is a method of protection, re-write the script or use output buffering. Quote Link to comment Share on other sites More sharing options...
Ruzzas Posted March 21, 2010 Share Posted March 21, 2010 you can just use die(); Quote Link to comment Share on other sites More sharing options...
trq Posted March 21, 2010 Share Posted March 21, 2010 As that generates an headers already sent error. (When using the script after any html) Why are you outputting anything if all your going to do is redirect? It makes no sense. Quote Link to comment Share on other sites More sharing options...
greatstar00 Posted March 21, 2010 Share Posted March 21, 2010 when you try to output, store them into a variable then at the last line, just echo that variable (this wont make u send anything before the header, just use 1 <?php ?>) 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.