Re: [PHP] Session Variable Problem

[email protected] ("Gary")
Newsgroups php.general
Message-ID <[email protected]>
Thanks again for all the help, however the plot thickens.

I have put:

<?php if(!isset($_SESSION)) {
    session_start();
 }
 if (isset($_POST['lend_fname'])){
$_SESSION['lend_fname']=stripslashes($_POST['lend_fname']);
}
if (isset($_POST['lend_lname'])){
$_SESSION['lend_lname']=stripslashes($_POST['lend_lname']);
}
if (isset($_POST['lend_street'])){
$_SESSION['lend_street']=stripslashes($_POST['lend_street']);
}
if (isset($_POST['lend_city'])){
$_SESSION['lend_city']=stripslashes($_POST['lend_city']);
}
if (isset($_POST['lend_state'])){
$_SESSION['lend_state']=stripslashes($_POST['lend_state']);
}
if (isset($_POST['lend_lname'])){
$_SESSION['lend_zip']=stripslashes($_POST['lend_zip']);
}
if (isset($_POST['lend_email'])){
$_SESSION['lend_email']=stripslashes($_POST['lend_email']);
}
if (isset($_POST['lend_phone'])){
$_SESSION['lend_phone']=stripslashes($_POST['lend_phone']);
}

?>

On the first page, Now what happens is it only sticks to the first two 
(lend_fname and lend_lname), the others still get lost. Any idea how or why 
the exact code works differently?

Thanks Again.

gary




"tedd" <[email protected]> wrote in message 
news:p06240800c7cbc092762b@[192.168.1.102]...
> At 2:22 PM -0400 3/20/10, Gary wrote:
>>I have this perplexing issue of session varibles getting dropped.  It is a 
>>4
>>page form, the last page being a review page incase the submitter wants to
>>change any of the information.If you go through the form, all of the
>>information carries forward, and from the review page if you go back to
>>edit, it is there, however is you go back to page 2, then to page 1, page
>>one info is gone.It gets worse in that page 2 sessions drop (more likely
>>over written) if you go from page 3 to 2.
>>
>>Each page is started with
>>
>><?php if(!isset($_SESSION)) {
>>     session_start();
>>  }
>>
>>Session varible:
>>
>>$_SESSION['lend_fname']=stripslashes($_POST['lend_fname']);
>>
>>Calling the session varible to the input field for review
>>
>><?php if (isset($_SESSION['lend_fname'])) {echo
>>'value="'.htmlentities($_SESSION['lend_fname']).'"';}?>
>>
>>The page starts at http://www.paulgdesigns.com/one2one/lend_bor_input.php
>>
>>Im confused as to why they keep getting dropped and how to stop it.
>>
>>Hopefully I have given enough information.
>>
>>Thank you
>>
>>Gary
>
> Gary:
>
> I think I know what the problem is. When you revisit previous pages, you 
> write over the previous data from an empty $_POST. Here's a way to stop 
> that.
>
> <?php session_start();
>
> if (isset($_POST ['lend_fname'])
>   {
>   $_SESSION['lend_fname'] = $_POST['lend_fname'];
>   }
>
> As far as using strip_slashes() and htmlentities() I wait until I am going 
> to use the variables in some manner and then clean/scrub them all at one 
> time. That makes the process simpler for me -- plus I can then keep all my 
> security checks in one location.
>
> Cheers,
>
> tedd
>
> -- 
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> __________ Information from ESET Smart Security, version of virus 
> signature database 4962 (20100321) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
> 



__________ Information from ESET Smart Security, version of virus signature database 4962 (20100321) __________

The message was checked by ESET Smart Security.

http://www.eset.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.