2

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&id=d59541b89828da34e9a8345a1bdafe2b but the redirection is made to http://xxxxxxxx/play.php? (without the php option)

1
  • 1
    btw the thingies that get lost aren't specific to PHP, but to HTTP in general and called URL parameters. Not sure if that's the official title actually but maybe it helps attract people to the question if you call them like that.
    – Nicolas78
    Aug 4, 2010 at 12:37

2 Answers 2

1

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.

2
  • echo 'alert("'.$redirect.'")'; displays xxxxxx/play.php?action=play (without option)
    – kossibox
    Aug 4, 2010 at 13:06
  • 1
    that's strange. but maybe there's actually in linebreak in your string after the & ? because it also shows as a linebreak in your question (the id begins in a new line).
    – Nicolas78
    Aug 5, 2010 at 8:14
0

If you change the line:

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

to this:

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

What happens?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.