Posted by Rik on 10/18/06 14:36
Garry Jones wrote:
> This is a excerpt from the code where I collect data with a form.
>
> <FORM action="index15dq.php" method="post" name="stegscf_pwd_edit"
> id="stegscf_pwd_edit">
>
> I am setting three session variables to already declared variables. I
> then echo them and can see on the resulting form that they are set
> correctly.
>
> <?
> session_start();
> $_SESSION['scf_upd_pwd'] = $scfmpwd1;
> $_SESSION['scf_upd_num'] = $scfchknum;
> $_SESSION['scf_upd_nam'] = $scfmfor;
> echo $_SESSION['scf_upd_pwd'];
> echo $_SESSION['scf_upd_num'];
> echo $_SESSION['scf_upd_nam'];
>>
>
> On the processing page - index15dq.php - I have this code.
>
> <?
> error_reporting(E_ALL);
> session_start();
> $scfmpwd1 = $_SESSION['scf_upd_pwd'];
> $scfchknum = $_SESSION['scf_upd_num'];
> $scfmfor = $_SESSION['scf_upd_nam'];
> print "values";
> echo $scfmpwd1;
> echo $scfchknum;
> echo $scfmfor;
>>
>
> Its echoing blank values. No errors reported.
>
> Shouldn't this work? How can I force session varables to work. Does it
> matter where session_start is declared?
Yes. print_r($_SESSION); to check what your session actually holds.
Be warned that session_start() has to be declared BEFORE any output, or it
won't work. So not in 'the centre' of your page, but as one of the first
things 'on top'. Even sending out a simple space or line-break before
session_start() will render it useless.
Another word of advice: don't rely on shorttags: always use <?php instead
of <?
--
Grtz,
Rik Wasmus
Navigation:
[Reply to this message]
|