I am not very experienced with PHP, so forgive me If I don’t get the terminologies right.
I have site that has a custom login area. The login form is located here: http://my-site.com/login-area/
When I logout I am redirected to this page which also displays the same login form: http://my-site.com/login-area/?logout=1
Instead of seeing the same login form when I logout , I would like my viewers to be redirected to this page when they logout: http://my-site.com/logout-area.html
Is there any way, I can do that?
Any help on this issue would be highly appreciated.
Thanks for the fast reply.
As I said I am new to PHP so I don’t know where to put the code that you provided me.
I have uploaded my login page php file so that you can check it and tell me where to put the code.
Login Page File: http://talalanwar.com/login-page.txt
Once again, Thank you.
Again, Thank you for the response.
I think that the code is included in another page (not standalone) because both the login and logout and some other code is in the same page.
BTW I put the code at the top but it isn’t working. Maybe there is another way of doing this?
@elitezero – if you want more help, you’re going to have to describe your problem in more detail..
“It doesn’t work” is useless information – after all, if it did work, would you still be asking for help? You need to tell us what actually happens, vs. what you expect. It is also helpful to share the code in question (this doesn’t work too well in the discussion forums – you can post code on pastebin or moke a gist on github).
I have given up on this. Instead of redirecting the user, I have added a link on the login form which allows users to return to the page in question.
Well, if it works and you’re happy with it, that’s fine. If not, however, don’t give up so quickly!
Thank you for everything.
Also, since no one mentioned this. This is a header function meaning no output can be sent before the header function is called. So if say you have an additional page outputting a header for the layout or any other html or output is released before the header() function the script will fail.
Hi, this is my login page.
Where should I put the code.
Hi, this is my login page. Where should I put the code.
The forum isn’t a great place to share large amounts of code. As you can see, a lot of your code will be mangled and won’t display correctly. You might try pastebin or make a gist on github instead, and then share the link.
To answer your question, in general, something like this should appear as close to the beginning of your script as possible. As @BradMetcalf mentioned, if there is any output to the browser beforehand, the
header function won’t work. Since you’re getting the request to log out via
$_REQUEST, then it’s probably safe to say that it could be the first thing you do.
You must be logged in to reply to this topic.