views:

41

answers:

2

hello, i'm triying to use javascript redirect to main window after log in succeed in an iframe. this is my code :

    if ($_GET['redirect']!='') {
    $redirect=$_GET['redirect'];
    $smart->assign('redirect',$redirect);
}
$redirect=$_GET['redirect'];
echo $redirect;

if(isset ($_SESSION['user'])&&$_SESSION['user']!='') {

    $user->email=$_SESSION['user'];
    $user->addCorporate();
    $user->signIn();
    $user->loadSession();

    echo("<script language=\"javascript\" type=\"text/javascript\">");
    echo "document.write('redirecting...');";

    if ($redirect!='') {
       echo 'self.parent.location = "'.$redirect.'"';
   } else
        echo 'self.parent.location = "index.php"';
     //echo $redirect;

   // redirect($redirect);
    echo "</script>";
}

the echo $redirect displays http://xxxxxxxx/play.php?action=play&amp;id=d59541b89828da34e9a8345a1bdafe2b
but the redirection is made to http://xxxxxxxx/play.php? (without the php option)

any ideas on how to fix this?

thank you in advance.

+1  A: 

This sounds pretty mysterious. Here's how I'd proceed: Turn off JavaScript in your browser and examine your created JavaScript. Then, at least, you know whether maybe for some bizarre reason the wrong URL is print out after all, or whether the problem's in the redirection part.

Nicolas78
echo 'alert("'.$redirect.'")';displays xxxxxx/play.php?action=play (without option)
kossibox
Nicolas78
A: 

If you change the line:

 echo 'self.parent.location = "'.$redirect.'"';

to this:

 echo 'alert("'.$redirect.'")';

What happens?

Click Upvote
hello,the alert displays http://xxxxxx/play.php?action=play (without ooption)
kossibox