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' ) ;
		}

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(); 
    } 



Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.