SESSIONS

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy

    SESSIONS

    Hi all,

    I'm trying to get the hang of Sessions using this little test program
    shown below. However, the first page starts up a couple of session
    variables (if they have not been started already), and invites the
    user to enter a name. The second page then takes this name, adds it
    to an array, and invotes the user to go back to the original page
    (where hopefully his name has been added).

    Any comments appreciated, Thanks

    Andy


    //sessionTest1.ph p
    <?php
    session_start() ;
    header("Cache-control: private");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    error_reporting (E_ALL);
    ini_set('displa y_errors', '1');

    ?>
    <html>
    <body>
    <form action ="sessionTest2. php" method = "post">
    <p>Enter your name:</p>
    <input type = 'text' name = 'textEntry'/>
    <input type = 'submit' value='submit'/>
    </form>

    <?php

    $condition=isse t($names);
    if(!$condition)
    {
    $names = array();
    $i = 0;
    $_SESSION['i'] = $i;
    $_SESSION['names'] = $names;
    }
    else
    {
    $names = $_SESSION['names'];

    for($i=0; $i<count($names ); $i++)
    {
    echo "$names[$i]";
    }

    }

    ?>

    </body>
    </html>

    -------------------------------------------------------------------------

    //sessionTest2.ph p
    <?php
    session_start() ;
    header("Cache-control: private");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    ?>

    <html>
    <body>
    <form action = 'sessionTest.ph p' method = 'post'>
    <input type = 'submit' value = 'back'/>


    <?php



    $names = $_SESSION['names'];
    $count = $_SESSION['count'];
    $lastName = $_POST['textEntry'];


    $names[$count] = '$lastName';



    $_SESSION['names'] = $names;
    $tester = $_SESSION['names'];
    echo $tester[0];
    //header("Locatio n: sessionTest.php ?output=$foo");




    ?>
    </form>
    </body>
    </html>
  • Geoff Berrow

    #2
    Re: SESSIONS

    I noticed that Message-ID:
    <b252a1fa.04040 80930.24e3a08d@ posting.google. com> from Andy contained
    the following:
    [color=blue]
    >Any comments appreciated, Thanks[/color]

    The weather is changeable isn't it?

    --
    Geoff Berrow (put thecat out to email)
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs http://www.ckdog.co.uk/rfdmaker/

    Comment

    • Pedro Graca

      #3
      Re: SESSIONS

      Andy wrote:
      (snip)[color=blue]
      > -------------------------------------------------------------------------
      >
      > //sessionTest2.ph p
      > <?php
      > session_start() ;
      > header("Cache-control: private");
      > header("Cache-Control: no-store, no-cache, must-revalidate");[/color]

      You missed the all important error reporting here, in sessionTest2.ph p

      error_reporting (E_ALL);
      ini_set('displa y_errors', '1');

      --
      USENET would be a better place if everybody read: : mail address :
      http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
      http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
      http://www.expita.com/nomime.html : to 10K bytes :

      Comment

      • Chung Leong

        #4
        Re: SESSIONS

        LOL

        "Geoff Berrow" <blthecat@ckdog .co.uk> wrote in message
        news:694b701km2 n8i0hbdddh2qomk 1qfvs89np@4ax.c om...[color=blue]
        > I noticed that Message-ID:
        > <b252a1fa.04040 80930.24e3a08d@ posting.google. com> from Andy contained
        > the following:
        >[color=green]
        > >Any comments appreciated, Thanks[/color]
        >
        > The weather is changeable isn't it?
        >
        > --
        > Geoff Berrow (put thecat out to email)
        > It's only Usenet, no one dies.
        > My opinions, not the committee's, mine.
        > Simple RFDs http://www.ckdog.co.uk/rfdmaker/[/color]


        Comment

        • Andy

          #5
          Re: SESSIONS

          Geoff Berrow <blthecat@ckdog .co.uk> wrote in message news:<694b701km 2n8i0hbdddh2qom k1qfvs89np@4ax. com>...[color=blue]
          > I noticed that Message-ID:
          > <b252a1fa.04040 80930.24e3a08d@ posting.google. com> from Andy contained
          > the following:
          >[color=green]
          > >Any comments appreciated, Thanks[/color]
          >
          > The weather is changeable isn't it?[/color]

          Thanks geoff.

          Comment

          • Geoff Berrow

            #6
            Re: SESSIONS

            I noticed that Message-ID:
            <b252a1fa.04040 81640.54f44565@ posting.google. com> from Andy contained
            the following:
            [color=blue][color=green][color=darkred]
            >> >Any comments appreciated, Thanks[/color]
            >>
            >> The weather is changeable isn't it?[/color]
            >
            >Thanks geoff.[/color]

            No problem. :-)

            Since you didn't actually ask a question, it was as good as any...

            --
            Geoff Berrow (put thecat out to email)
            It's only Usenet, no one dies.
            My opinions, not the committee's, mine.
            Simple RFDs http://www.ckdog.co.uk/rfdmaker/

            Comment

            • Andy

              #7
              Re: SESSIONS

              > No problem. :-)[color=blue]
              >
              > Since you didn't actually ask a question, it was as good as any...[/color]

              Fair comment...

              Anyway, I live in Glasgow where the weather isn't changeable at all.
              It always bloody rains ;-)

              I'll try to make more appropriate postings in future.

              Andy

              Comment

              Working...