Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP and Frames

Options
  • 13-07-2004 11:52am
    #1
    Registered Users Posts: 3,548 ✭✭✭


    I have a page with a few frames in it. In one of the frames is a log in box. When the user clicks log in, I want the page to redirect to another page, either the secure section, or back on itself.

    Everything is working grand except for one problem. Im using a header() to redirect the page on login. With the current system, the new page is opening within the same frame as the login box. The rest of the page is staying the same. So basically, how do I redirect to an entirely new page using a header(), rather than opening that page within a frame?.

    If it cant be done with header() does anyone know a way to redirect to a new page in a PHP script after doing some validation on a few variables?


Comments

  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    The easiest way would be

    If it is a log in form, use the following


    <form method="post" action "validate.php">

    </form>

    Send the variables to a validation page

    If validation is successful you can use an include to show the information they are allowed see, or if validation fails use an include to re-show the form again, telling them the specific problem with their log-in


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    It sounds like if the login is successful then the user should leave the frames system to just a single page if that's the case have you tried target="_top" in your form definition, I'm not sure if it just works for links or will it do the trick for a form submit too, if it does it will break out of the frames system.

    If you're trying to have them login in the top frame and display stuff in the bottom if they're logged in, for e.g. show stuff.htm if logged in, show blank.htm if not

    Set up your frames to show login page and blank.htm by default
    Validate login by whatever means (generally either submitting a form back to the same page or another page)
    If login succeeds output something like

    <body onLoad="parent.frames[1].location='stuff.htm';">

    You might have to play with the index for frames[] if you have more than just top/bottom frames.



    Steve


  • Registered Users Posts: 6,163 ✭✭✭ZENER


    Try putting your header() before the <head> tag on your page. This must be inserted before the HTTP headers are sent !

    ZEN


  • Registered Users Posts: 14,003 ✭✭✭✭The Muppet


    Originally posted by Draupnir
    I have a page with a few frames in it. In one of the frames is a log in box. When the user clicks log in, I want the page to redirect to another page, either the secure section, or back on itself.

    Everything is working grand except for one problem. Im using a header() to redirect the page on login. With the current system, the new page is opening within the same frame as the login box. The rest of the page is staying the same. So basically, how do I redirect to an entirely new page using a header(), rather than opening that page within a frame?.

    If it cant be done with header() does anyone know a way to redirect to a new page in a PHP script after doing some validation on a few variables?


    Have you tried setting the target as _parent. That would do it for html but I,m not very familar with php .


  • Closed Accounts Posts: 35 Ivan Dunaev


    it's impossible to do with header()
    use javascript to reload frames after validation
    for example in onload event in your login box frame


  • Advertisement
  • Registered Users Posts: 1,268 ✭✭✭hostyle


    Originally posted by Ivan Dunaev
    it's impossible to do with header()
    use javascript to reload frames after validation
    for example in onload event in your login box frame

    Not knowing much about PHP, are you sure you can't specify a Target in your header? You can in perl ...


  • Closed Accounts Posts: 35 Ivan Dunaev


    well, i heard about this stuff, something like that:
    header('Location: somelocation');
    header('Window-target: _target');

    but i also heard it doesn't work everywhere.
    i'm trying not to use frames if it's possible, so can't tell more exact


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Originally posted by Ivan Dunaev
    well, i heard about this stuff, something like that:
    header('Location: somelocation');
    header('Window-target: _target');

    but i also heard it doesn't work everywhere.
    i'm trying not to use frames if it's possible, so can't tell more exact

    Am but PHP is server side...it doesn't know frames. It only executes its own page and no's bout nothing else


  • Closed Accounts Posts: 35 Ivan Dunaev


    true, but it can return header telling browser what to do
    "This header will force the document to load in the window named window_name, or if such a window does not exist, one will be created, and then the document will be loaded in it. This header has usefullness in farmes, and potentialy could be used in a multipart message to fill multiple frames with one CGI"
    search google for more info


  • Registered Users Posts: 1,268 ✭✭✭hostyle


    Originally posted by Webmonkey
    Am but PHP is server side...it doesn't know frames. It only executes its own page and no's bout nothing else

    Technically you're correct , but in this instance the PHP server response is passing instructions to the client browser. How the browser interprets those instructions is certainly not reliable, but in most cases it will work. To learn more look up the HTTP protocol RFC, in particular the HEADER section.


  • Advertisement
Advertisement