iFrame + PHP Help
- Started
- Last post
- 3 Responses
- spot13
I have a page (1) with an iframe that loads another page (2). I want to ensure that the page(2) cannot be accessed directly so it would need to check the parent URL. Any ideas on a secure way PHP could be used to redirect or logout a user if they were trying to access a page directly instead of inside an iframe.
- bigtrickagain0
you could do it in javascript...
<script language="javascript">
if(window.location == top.location) {
top.location.href="logout.php";
}
</script>- Thx for the quick reply, that's an option. My concern is if you disable JS, would you be able to access the content?spot13
- without js, the iframe would not redirect if accessed directly, nobigtrickagain
- It might be possible to enforce the use of JS by making the content load through xmlhttp requests.spot13
- bigtrickagain0
or in javascript with php to set the redirect url:
<script language="javascript">
if(window.location == top.location) {
top.location.href="<?php echo "logout.php" ?>";
}
</script>
- bigtrickagain0
if you want to do it all in php, you could check the $REQUEST_URI variable - if it corresponds with the address of the iframe and not the frameset, you can redirect...