Give help. Get help.

  • # September 16, 2013 at 9:17 am


    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:

    When I logout I am redirected to this page which also displays the same login form:

    Instead of seeing the same login form when I logout , I would like my viewers to be redirected to this page when they logout:

    Is there any way, I can do that?

    Any help on this issue would be highly appreciated.

    # September 16, 2013 at 9:23 am

    You could try putting this in the login page (untested, just from the top of my head):

    $loggedout = Request.QueryString("logout")
    if ($loggedout == 1) {
        header( 'Location:' ) ;
    # September 16, 2013 at 9:30 am

    Hi 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:

    Once again, Thank you.

    # September 17, 2013 at 6:11 am

    I 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

    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?

    # September 17, 2013 at 8:37 am

    Actually, this


    is not valid PHP. (Looks like you’re in javascript mode, Senff!)

    if( isset( $_REQUEST['logout'] ) ) {
        header( 'Location:' ) ;
    # September 17, 2013 at 8:43 am

    Hi 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

    Looks 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

    @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

    Hi 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

    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.

    no problem.

    # September 27, 2013 at 12:53 am

    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.

    # September 27, 2013 at 2:45 am

    Hi, this is my login page.

    Where should I put the code.

    <body class="main">




    <a href="/?cd=”><img alt="BCK File Portal" src="/include/views/img/logo.gif”>


    <a href="”>

    <button type="button" class="nice secondary radius button paste-selected"”>

    # October 1, 2013 at 11:52 am

    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.

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.