Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Redirect PHP Query to .HTML Page

  • This topic is empty.
Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #150212
    EliteZERO
    Participant

    Hi,

    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.

    #150214
    Senff
    Participant

    You 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' ) ;
        }
    
    ?>
    
    #150216
    EliteZERO
    Participant

    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: http://talalanwar.com/login-page.txt

    Once again, Thank you.

    #150288
    Senff
    Participant

    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.

    #150303
    EliteZERO
    Participant

    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?

    #150311
    __
    Participant

    Actually, 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' ) ;
    }
    
    #150312
    EliteZERO
    Participant

    Hi traq,

    Thanks for the response.

    But your code doesn’t work. I put it inside the file at the top.

    #150356
    Senff
    Participant

    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-

    #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).

    #150692
    EliteZERO
    Participant

    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.

    #150754
    __
    Participant

    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.

    #151367
    Brad Metcalf
    Participant

    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.

    #150215
    EliteZERO
    Participant

    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”>




    $value):?>

    <a href="”>




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

    #151493
    __
    Participant

    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)
  • The forum ‘Back End’ is closed to new topics and replies.