#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    2
    Rep Power
    0
    I'm using PHP to create a cookie on my index page, that has an HTML inside the and wanting to carry the variable over to the frames page so I can say Hello to the user. The PHP script is:
    =====================
    <?php

    if($action == "setcookie") {
    setcookie("visitorname", "$visitorname", time() + 50);
    // expires sooner than you think!
    }

    if(isset($visitorname)):

    ?>

    <html>

    <head>
    <title>CGI Class Resources</title>

    </head>

    <frameset rows="121,*" framespacing="0" border="0" frameborder="0">
    <frame name="top" scrolling="no" noresize target="contents" src="header.php">
    <frameset cols="209,*">
    <frame name="contents" target="main" src="blank.htm" scrolling="auto" noresize>
    <frame name="main" src="cgi-main.htm" scrolling="auto">
    </frameset>

    <noframes>
    <body>

    <p><p><center>Our class page uses frames, but your browser doesn't support them. This page best viewed with IE 4 or better.
    </center></p></p>

    </body>
    </noframes>
    </frameset>

    </html>

    <? else: ?>

    <form>
    <center>
    <p>
    <input type = "hidden" name= "action" value="setcookie">
    <p>Welcome to the New Cookie Page Entry Screen. Input your name and it will set a small limited-time cookie on your machine. We will be setting Cookies with PHP as per Chapter 18 of PHP Professional Programming.<br><p>
    <input type="text" name="visitorname">
    </br>
    <p>
    <input type="submit" value="ok">
    </center>
    <p>

    </form>

    <? endif; ?>
    ========================
    Can I use the $visitorname variable in any of the frame pages?

    Dave



    ------------------
    D R Mynatt
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    yea,

    you can use the $visitorname variable in any of the frame pages.Because it is already set.so it should work fine!!!

    ------------------
    SR -
    shiju.dreamcenter.net
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    2
    Rep Power
    0
    Sir:
    I tried to use it and it won't produce an output. Here's what I did; perhaps I coded wrong.

    =========================
    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <title>CGI Class Header Page</title>

    <base target="contents">

    </head>

    <?php

    echo ("Welcome $visitorname");

    ?>

    <body background="graphics/vanillabak.gif" bgproperties="fixed" onLoad="scroller('Create a PHPSCRIPTsubdirectory on the same level as the publichtml directory. Store the PHP include files there.','all');"> <h1 align="center" style="word-spacing: 0; line-height: 100%; margin: 0"><b><font align="right" color="#AC094E" face="Times New Roman" size="4"><sub><img border="0" src="graphics/gears.gif" align="left" width="83" height="75"></sub>CGI<sub>
    </sub>PROGRAMMING TECHNIQUES<sub>
    &nbsp;</sub></font></b></h1>

    <snip>

    ==================

    Did I code wrong?

    Thanks for your help.

    Dave


    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by Shiju Rajan:
    yea,

    you can use the $visitorname variable in any of the frame pages.Because it is already set.so it should work fine!!!

    [/quote]



    ------------------
    D R Mynatt
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    63
    Rep Power
    15
    The scope of the $visitorname variable is only availible in the current page/script you are building, so you can not access it on the child frame unless you build it there. However, if you just put it in the url of the child frame, you'd have it. Eg. src="blank.htm?visitorname=$visitorname".

Similar Threads

  1. Replies: 11
    Last Post: February 21st, 2004, 06:48 AM
  2. include external page that uses cookies
    By micahbdavis in forum PHP Development
    Replies: 1
    Last Post: February 9th, 2004, 04:03 PM
  3. Replies: 0
    Last Post: February 8th, 2004, 10:11 PM
  4. passing the url from HTML page to a php
    By lordorkus in forum PHP Development
    Replies: 10
    Last Post: January 20th, 2004, 05:36 PM
  5. Replies: 4
    Last Post: January 6th, 2004, 03:56 PM

IMN logo majestic logo threadwatch logo seochat tools logo