1

Im working on on this website which basically its a php page with an iframe. The login page is displayed within the iframe and when all deatails are inserted correctly new options will show up on the main page. Now the prob is the after the login i have to hit the refresh button. I tryed to use the META tag but the main page is showing in the iframe. I would like the to find a way which the content changes on the main page appering as the main page not in the iframe.

4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by diafol
0

Hai,

Iframe is strongly not recommended for web sites now a days.

Please find any other way other than Iframe

Thanks
Rajeesh

0

Im working on on this website which basically its a php page with an iframe. The login page is displayed within the iframe and when all deatails are inserted correctly new options will show up on the main page. Now the prob is the after the login i have to hit the refresh button. I tryed to use the META tag but the main page is showing in the iframe. I would like the to find a way which the content changes on the main page appering as the main page not in the iframe.

Of course, if you just HAD to have it with the iframe, you could have a success page which contained:

<script>
self.parent.location.href='whatever.php';
</script>

Just a thought. My 2¢.

0

Thanks for your opinion, but I had to dump down the idea of using the iframe. I'm running against a dead-line and even my lecturer couldn't help me. I know it sounds like a laaameee excuse but I had to move on.

1

The login form could be an include file which appears in the banner area/sidebar if nobody is logged in. If somebody is successfully logged in (known via session variable) it just shows NAME logged in with a link 'logout' near it. Straightforward.

content of login.php

<?php
if(!isset($_SESSION['login'])){
   $output = "...place the login form here - send to loginhandler.php...";
}else{
   $output = "<p>{$_SESSION['login']} logged in</p><p><a href=\"logout.php\" title=\"logout from the site\">logout</a></p>";
}
?>

at the top of every page:

<?php
session_start();
include('login.php');
...
?>

Then at the appropriate place on every page (e.e. banner area):

<div id="login">
<?php echo $output;?>
</div>

content of loginhandler.php

<?php
if(isset($_POST['sendlogin'])){
//check if details in db and get details
//assume all OK:
$_SESSION['login'] = $data['username']; //from db
}
header("Location:{$_SERVER['HTTP_REFERER']}");
?>

content of logout.php

<?php
if(isset($_SESSION['login'])){
 unset($_SESSION['login']);
}
header("Location:{$_SERVER['HTTP_REFERER']}");
?>

This is really basic and doesn't really hit the mark w.r.t security/sanitizing - but should give you an idea. The $_SERVER means go back to the previous page. It could just as easily be index.php or any other page.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.