Ezilon.com - Target Your Audience, be Seen in Your Region

PHP URL Forwarding

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.
Reece S's picture

He has: 172 posts

Joined: Oct 2007

Hi, I have a PHP script, here...

Quote: <?
session_start();
if(!session_is_registered(username)){
header("location:SOMEPAGE");
}
?>

and I wanted to convert the...

Quote: header("location:SOMEPAGE");

To do this...

Quote: <script language="javascript">
function UpdateClose()
{
opener.window.location = "SOMEPAGE";
self.close();
}
</script>

Can someone please tell me if this is possible, and if so, how it can be done?
Thanks in advance.

pr0gr4mm3r's picture
ModeratorSponsor

He has: 708 posts

Joined: Sep 2006

What exactly are you trying to accomplish?

Reece S's picture

He has: 172 posts

Joined: Oct 2007

A downloader file.
It boots up in a popup window, and if they are loggin in, it converts the popup window into a "save file" window.
if they are not, it closes the window, and directs the main page into the login area.
with me?

pr0gr4mm3r's picture
ModeratorSponsor

He has: 708 posts

Joined: Sep 2006

Is the "save file" window one of your pages, or are you referring to the browser's safe file dialog?

Reece S's picture

He has: 172 posts

Joined: Oct 2007

The browser default.

pr0gr4mm3r's picture
ModeratorSponsor

He has: 708 posts

Joined: Sep 2006

I'm thinking you don't need a popup window at all then. Just use a PHP conditional. Redirect them to the file if they are active, or redirect them to the login page if they are not.

<?php
session_start
();
if(!
session_is_registered(username)){
header("Location: LOGIN\");
}
else
{
header(\"Location: FILE\");
}
?>
Reece S's picture

He has: 172 posts

Joined: Oct 2007

ahh, of course.
I was doing it wrong, the success status would leave the page as it is, and just open the file saver over the parent page.
the failed status would redirect the parent to login. this is great.
Cheers, i do make life complicated for myself. thanks a lot m8.