Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirecting header() if codition is met

Status
Not open for further replies.

camcim

Programmer
Jan 25, 2003
20
US
Hi all,
If i open a javascript pop up window from a page called genre.php:
Code:
<a href=&quot;#&quot; onClick=&quot;MM_openBrWindow('member_rating.php?movie_id=<? echo $movie_id ?>','rating','width=300,height=400')&quot;>Rate this</A>
how can i get the browser to go back to the genre.php page if the session is not valid?
In the member_rating.php page i check to see if a session exists.
If a session does not exist i have a header function that executes:
Code:
header(&quot;Location: login.php?id=member_rating&movie_id=$movie_id&quot;);
This all works fine except that the login.php page loads into the pop up window.
How can i get it so that if the session is not valid the login.php page displays but in the original genre.php page.

Cheers,
micmac
 
You know, I'm 99% certain you can't...

Whatever you're going to do won't really be PHP anyway, because (and I could be mistaken, but I'm fairly certain), PHP doesn't have any knowledge of which browser windows are open on the client machine.

I don't even think PHP can close that window for you... you can write out a quick little javascript function to close that window for you with your php script and call it from the onload event of the body...

so basically

if condition..

echo &quot;
<html><head>
function bye() {
self.opener=this;
self.close();
}
</head>
<body onload=\&quot;bye()\&quot;>
</body>
</html>
&quot;;

But that doesn't help with the redirect... and on that I'm stumped... but figured I'd volunteer as much in case it was useful for you.

-Rob
 
If I got it in the right way, I think instead of directly open an popup window from your current page. You need a validater page that can validate your session first and then do the rest as you condition. like,

On that particular click event that you are using to open an popup window, try to call a validater file lets say validate.php and from that file check if your session is expired then passed it back to the same page and if not then open an popup window for what ever you gonna do with it.

Might that help you :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top