Re: Don't mean to be repetitive - Session Variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Monday 11 October 2004 16:47, Stuart Felenstein wrote:
> I can't seem to figure this out.
> Right now I'm still trying to get the multi page form
> down.
> For the facts, running php 4.3.8, apache 1.3.x
> Register Globals are enabled

If you don't have a specific reason for this to be enabled you should disable 
it.

> So I'm starting the pages with:
> <?php
> session_start();
> ?>
>
> Now since this is a form, the user creates the value
> for the variable, so within the form:
>
> <input name="myname" type="text" id="myname"
> value="<?php echo $_SESSION['myname']; ?>">
>
> Question 1: is this enough to register the session
> variable ?

No. You should read (repeatedly if necessary)

  manual > Session Handling Functions

and try out the examples and understand what's going on.

Executive summary:

do not enable register_globals
$_SESSION['variable'] = 'something'; // to register a session variable

> If I send this form action post to a page where I
> have:
> <?php
> session_start();
> ?.
> ..............
> <?php
> echo "\$myname = ".$myname."<br/>";
> ?>

$myname is taken straight from your form, and because you have enabled 
register_globals it is available in the GLOBAL scope. That has nothing to do 
with your sessions.

> The variable print out fine.
> BUT - if I add another page between first and
> printout,
> echo "\$myname = ".$myname."<br/>"; - returns nothing

1) understand the paragraph above
2) realise that at no stage have you actually registered any session variables
3) realise that you have not propagated $myform from page2 to page3 either 
through a form or through the URL

hence $myname is not available on page3.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux