--- In [email protected], <[EMAIL PROTECTED]> wrote:
Hi Rob,
Thanks very much for the informative reply. Really appreciate it.
Added the code below as you suggested to the first form:
page line 1 => <?php
page line 2 => session_start();
etc...
if(isset($_POST['uzername']))
{
$uzername = $_POST['uzername'];
session_register($uzername);
}
if(isset($_POST['passwordd']))
{
$passwordd = $_POST['passwordd'];
session_register($passwordd);
}
?>
<html>
<form action=....
<input type="text" name="uzername" value="<?php echo($uzername); ?>">
<input type="password" name="passwordd" value="<?php
echo($passwordd); ?>">
where form action already existed but did try again using <?php
echo($uzername); ?> as my 'value'. I even tried placing a link from
page 2 back to 1 directly in hopes those values would autofill for the
two text fields but no such luck. Is there something else I should do
to return the values? i.e. place a $passwordd = $_POST['passwordd'];
in that particular code on page 1. Also am assuming that once the
session/cookie is started on page 1 lines 1 and 2 (<?php on line 1 and
session_start(); on line 2 of the page), nothing else needs to be done
for other pages as, the cookie set in page one holds contents for the
variables until the browser window is closed. Hope that's not a
faulty assumption. ;-)
Again, thanks very much.
John
> -----------------------------
> Hello John,
> Fortunately this is very simple in PHP.
>
> There is only two traps to watch out for. One is a PHP configuraion
> environment vairiable "Register Globals" and it can cause security
problems
> so it is best dissabled or you should prevent it from causing problems.
>
> The other is that you must NOT send anything from the server, even a
space
> or carage return before you start the session. This is because the
operation
> to set a cookie is sent in the headers from the server and the
server can
> only send the headers once.
>
> for example -
> /// file starts on next line
>
> <?php
> session_start();
> ....
>
> will not work because of the blank line before <?php and the server
will
> send the headers along with the blank line before is starts the
session and
> as a result the server cannot set the cookie.
>
> PHP also realises when cookies are dissabled and it will append
serssion
> information to urls in a page for example
> <a href=http://mydomain.com/mypage.php?SID=83287383u32h238>
> instead of
> <a href=http://mydomain.com/mypage.php>
>
> ok - the register globals problem -
>
> If you have a script that says -
> <?php
> ....
> if($loggedin == TRUE) {...
>
> then some can write HTML
> <form action=...
> <input "loggedin" value = "1">
>
> and if Register globals is enabled then they can get loggedin status
>
> To prevent this always clear important varialbes in php
>
> <?php
>
> $loggedin="0";
> If($_POST['password'] == $password)
> {$loggedin = "1";
> .....
>
> Ok back to your question - There are two ways of doing this, one is
with
> Javascript and I wont go into that, the other is session variables.
>
> <?php
> session_start();
>
> if(isset($_POST['uzername']))
> {
> $uzername = $_POST['uzername'];
> session_register($uzername);
> }
>
> if(isset($_POST['passwordd']))
> {
> $passwordd = $_POST['passwordd'];
> session_register($passwordd);
> }
>
> ?>
> <html>
> ....
> <form action=....
> <input type="text" name="uzername" value="<?php echo($uzername); ?>">
> <input type="password" name="passwordd" value="<?php
echo($passwordd); ?>">
>
> Hope that helps, Rob.
>