Jump to content

Redirecting to a page on the top frame with php


phpchick

Recommended Posts

I have a program that is loaded into an iframe, more specifically the fancybox modal window app. It is the one here http://www.phpfreaks.com/forums/index.php?topic=332297.0 which dragonSA and others so graciously helped me with.

 

On completion of the program (no errors), I want it to redirect the entire page to a new one. (the user successfully logs in)

 

The problem it seems is that my header('URL'); redirects to the page, but within the iframe. I want the top frame to redirect, and obviously closing the modal window.

 

I did some research and it seems that frames are client-side while PHP is getting processed server-side so it's unable to target another frame. I believe that this makes it out of PHP's scope to do this, but I am not sure.

 

I did some more research and a lot of people on the web are using javascript to do this, but none of the examples showed how it could be implemented in something like mine (after a true if statement inside the php script).

 

 

// the following code is inside a <?php ?> statement

if (count($aError) == 0) {


  header( 'Location: http://www.site.com/welcome.html' ) ;
		}

Link to comment
Share on other sites

I got it working, all I did was paste this code where I wanted the redirect instead of the header I had earlier.

 

 

if(!isset($_SESSION['SESS_USERID'])||(trim($_SESSION['SESS_USERID']=='admin'))) 
    { 
        echo '<script language="javascript">'; 
        echo 'top.location.href = "../accessDenied.php";'; 
        echo '</script>'; 
        exit(); 
    } 



Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.