Redirect in iframe in php

My Situation:
I am bridging Copermine Photo Gallery and phpBB together. I followed the instructions (edited the appropriate bridge files, uncommented the right code) and it works.

My Problem:
When I press Login from Coppermine, it sends me to phpBB to login, and that's what it's supposed to do. What it's supposed to do next is redirect me back to Coppermine after I have successfully logged in, it does that too! So the real problem is how it redirects.

Normally the Coppermine index.php is situated inside an iframe in my webpage, but as soon as I login successfully in phpBB, it redirects the WHOLE page to Coppermine, no longer within the iframe.

So here's the process:
Coppermine >>>> login @ phpBB >>> Coppermine
(inside iframe)>>>(inside iframe) >>>(not in iframe anymore [full page], but I want it to be)

So here's why it's in the PHP section:
I think I pinpointed the code that redirects back to Coppermine after a login, it's inside the cpg_redir.php file inside my forum directory (cpg = coppermine photo gallery):

<?php
if (!$_SERVER['HTTP_HOST']) {
  $cpg_host=$HTTP_SERVER_VARS['HTTP_HOST'];
} else {
  $cpg_host=$_SERVER['HTTP_HOST'];
}
$cpg_path='/cpg133';
header("Location: http://".$cpg_host.$cpg_path);
exit;
?>

I believe that the header("Location: http://".$cpg_host.$cpg_path); statement is causing this problem.

So here's my question:
How do you redirect to a page INSIDE an iframe using PHP?
LVL 2
billyeaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bugadaCommented:
You should use target, but unfortunately header cannot have targets - it reloads the page from scratch because by it's very nature it must operate before any code is sent. Your workaround may be to have a copy of the original page of your site that will load the Copermine page into iframe. in the previous code just redirect on that page instead of the Coppermine one...
billyeaAuthor Commented:
I wonder if is possible to put JavaScript code inside PHP (remember, I'm a newbie so I wouldn't know, I just edit what feels right), so that I could put a 'window.location(...)' statement, or possibly popup code (from what I heard, a popup call will not create a popup while it is inside an iframe but will paste the page back into the iframe).

Possibly put the code after the php code ends? I don't want to have too many files on my hands.

I will try your method though, and report if it works.
billyeaAuthor Commented:
Well, I just encountered something strange.

I replaced:

<?php
if (!$_SERVER['HTTP_HOST']) {
  $cpg_host=$HTTP_SERVER_VARS['HTTP_HOST'];
} else {
  $cpg_host=$_SERVER['HTTP_HOST'];
}
$cpg_path='/cpg133';
header("Location: http://".$cpg_host.$cpg_path);
exit;
?>

With a more direct version:

<?php
header("Location: http://dtodyssey.stonerocket.net/cpg133/index.php");
exit;
?>

And suddenly everything starts working again. I don't know the difference, but I'm happy as long as it works.
Hrm...is it ok if I close this question?
bugadaCommented:
Yes of course, ask a refund for the points since you have solved your problem by yourself...
Andrea
LunchyCommented:
Closed, 125 points refunded.
Lunchy
Friendly Neighbourhood Community Support Admin

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.