lonewolf217 Posted June 17, 2008 Share Posted June 17, 2008 I know there is a way to use a header to automatically redirect as soon as they hit your page, but unfortunetly that is not what I wanted. I got spoiled with .asp using the Response.Redirect to redirect users back to a particular page after running my background scripts but I cannot figure out a way to do the same with php since I have read that the header must be the ONLY line in the file else it will not work. Is there an exception to this, or is this just the nature of php ? Quote Link to comment Share on other sites More sharing options...
trq Posted June 17, 2008 Share Posted June 17, 2008 A call to header() works fine. It just needs to be made before any output which makes perfect sense seeing as outputting something and then redirecting makes no sense at all. The only reason you can get away with the same thing in asp is because of a hack that has your entire output placed within a buffer. This can also be done in php but as I said, it is a hack. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 17, 2008 Share Posted June 17, 2008 You can try using meta redirects if you want to show them a message, but otherwise, just put the header calls in the appropriate place. Quote Link to comment Share on other sites More sharing options...
lonewolf217 Posted June 17, 2008 Author Share Posted June 17, 2008 so you are saying as long as I dont output anything I can still use the header redirect later down the page ? like if I have the PHP script to insert data into the database but I have no echo or print statements, then at the bottom of the script I can have a redirect back to the main page Quote Link to comment Share on other sites More sharing options...
jesushax Posted June 17, 2008 Share Posted June 17, 2008 yeah thats right Quote Link to comment Share on other sites More sharing options...
lonewolf217 Posted June 17, 2008 Author Share Posted June 17, 2008 thanks, I was able to get it working perfectly! 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.