Hi! i'm currently developing a system using php and mysql. I ony have 1 problem left. How can I disable the browser's back button to prevent the user who have logged out from going back to the previous page? I have tried the
header ("Location: PAGENAME");
but an error telling me that the header was already been sent appears. PLease help. Thank you.
By the way, im using Internet explorer.
In order to use the header() section, you must call the function before any output is sent to the user (because that's when headers are sent). Make sure you open your <?php code block at the very beginning of the file and don't echo/print any output before the header() function.
Also, how are you using the header function? Perhaps I'm misunderstanding you, but preventing the user from going backwards isn't the best way to keep a user from logging out and then going back to protected information. When they are logged in, there should be some info (cookie/session data) that says they are logged in, and that should be canceled out when they are logged out. Then, if that data shows them to be logged out, the protected page should redirect the user using the header() function.
But, perhaps that's what you're already trying to do and I was a bit confused by your wording.
If you can't figure it out, paste your source code here and someone can probably find the point where you're outputting some data.
I don't think there *is* a way of disabling the user's back button - it's the user's, not yours. As stated, they won't be able to get back into protected content anyway if they're logged out, so you needn't worry.
Does this help?
Hey guys! thanks for all these replies. I just presented the system that I created yesterday. Before I present I was required to debug, and configure the server (Which is up to you to figure if the server needs to be configured). I had a 100. so far the highest (for no one thought that the server was not configured). Thanks for all these replies once again. I really appreciate it because it made me feel challenge to do new thing like disabling the back button.
this is the code that i used:
Its not that impressive but it works. put it on the page before the logout page.