I'm trying to design a page which does some database actions, then redirects to user back to the page they came from. The problem is that I use a require()
function to get the connection to the database, so the headers are already sent. A meta tag is out of the question since I want it to look like all the processes are done from the page they came from. Any tips? Is there a way I can use the require()
and the header()
or do I have to drop one? Is there an alternative to header()
?
If you can't send the header()
before some content gets sent, use output buffering by placing an ob_start();
at the beginning of your script before anything is sent. That way, any content will be stored in a buffer and won't be sent until the end of the script or when you manually send the buffer's contents.
On another note, simply require
ing another file would not generate any headers/content unless that included script sends them. The most common "hidden" cause of this is unnoticed whitespace before or after the <?php ?>
tags.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With