refresh an ifrarme .php from another iframe

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
StorM_GmA
Forum Newbie
Posts: 4
Joined: Mon Jun 30, 2008 9:42 am

refresh an ifrarme .php from another iframe

Post by StorM_GmA »

Hello!

I have several iframes in my website and when the user logs in (through an iframe), I want to refresh another iframe in order to view his shopping cart. Here's the code from the iframe with the log in:

Code: Select all

 
<?PHP
    if (isset($_COOKIE["AVweb"])) {
        echo "Welcome, " . $_COOKIE["AVweb"] . '<a href="logout.php">(Log out)</a>';
        exit;
    }
?>
<html>
    <head>
        <title>
        </title>
    </head>
    <body>
    <form name="LogIn" method="post" action="LogInValidate.php">
        Username:
        <INPUT TYPE=text Name=txtUsr maxlength="20">
        Password:
        <INPUT TYPE=text Name=txtPass maxlength="20">
        <INPUT TYPE=submit Name=cmdSubmit Value="Submit">
    </form>
    </body>
</html>
 
So when the user presses the Submit button, the website should refresh the cartFrame.php. How can I do that? I tried the Header("Location: cartFrame.php") but it loads the cartFrame.php in the Log In iframe...

Thanks alot and sorry for the silly question...I just couldn't find some through google...
StorM_GmA
Forum Newbie
Posts: 4
Joined: Mon Jun 30, 2008 9:42 am

Re: refresh an ifrarme .php from another iframe

Post by StorM_GmA »

Hello again!

Well, I found out a way to refresh the iframe by using some javascript but it seems that there's a conflict with the Header command. Here's the code:

Code: Select all

<?PHP
    setcookie("AVweb", "", time()-3600);
    header("Location: login.php");
?>
<html>
    <head>
        <title>
        </title>
    </head>
    <body>
        <a href="logout.php">(Log Out)</a>
    <script language="javascript">
    <!--
    if (parent.frames['cart']){
            parent.frames['cart'].location.reload();
    }
    //-->
    </script>
    </body>
</html>
 
The javascript is working fine in another file (the other file doesn't have a Header) but in this one, when the Header is triggered, it seems like the browser never goes to the bottom. I tried to put the javascript code into a function and call it before the Header but I get an error. Is there any way to trick the browser and read the whole file?
Post Reply