- This topic is empty.
-
AuthorPosts
-
September 16, 2013 at 9:17 am #150212
EliteZERO
ParticipantHi,
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.
September 16, 2013 at 9:23 am #150214Senff
ParticipantYou could try putting this in the login page (untested, just from the top of my head):
<?php $loggedout = Request.QueryString("logout") if ($loggedout == 1) { header( 'Location: http://my-site.com/logout-area.html' ) ; } ?>
September 16, 2013 at 9:30 am #150216EliteZERO
ParticipantHi Senff,
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.
September 17, 2013 at 6:11 am #150288Senff
ParticipantI don’t know the context of your login page (if it’s standalone or included in another page, etc.) but you’ll need to put the code as early as possible in the page. You could try putting it all the way at the top of login-page.php and see if it does something.
September 17, 2013 at 7:42 am #150303EliteZERO
ParticipantAgain, 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?
September 17, 2013 at 8:37 am #150311__
ParticipantActually, this
Request.QueryString("logout")
is not valid PHP. (Looks like you’re in javascript mode, Senff!)
<?php if( isset( $_REQUEST['logout'] ) ) { header( 'Location: http://my-site.com/logout-area.html' ) ; }
September 17, 2013 at 8:43 am #150312EliteZERO
ParticipantHi traq,
Thanks for the response.
But your code doesn’t work. I put it inside the file at the top.
September 17, 2013 at 2:29 pm #150356Senff
ParticipantLooks like you’re in javascript mode, Senff!
I…… I don’t know what happened there. Geez. It was actually taken from an ASP file I was working on at the time. Oh my. -embarrassed-
September 17, 2013 at 4:24 pm #150367__
Participant@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).
September 20, 2013 at 3:05 am #150692EliteZERO
ParticipantHi traq,
Sorry for the late response.
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.
Thank you for everything.
September 20, 2013 at 9:06 am #150754__
ParticipantI 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.
no problem.
September 27, 2013 at 12:53 am #151367Brad Metcalf
ParticipantAlso, 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.
September 27, 2013 at 2:45 am #150215EliteZERO
ParticipantOctober 1, 2013 at 11:52 am #151493__
ParticipantHi, 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. -
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.