简体   繁体   中英

Session Variables Between Pages

I've got two pages with many text box inputs containing numbers.
The first page's form submits to the second page (where the text box values become session vars) and the second page submits all of the session vars to a processing page where they're added to the database.

I'm trying to make it where you can go back and forth between page 1 and 2, and all of your text values entered will stay the same.

This works for coming back to the first page because the second page initiates the variables and takes the POST.

However, I can't achieve the same effect going from the second page back to the first, and then back, because the second page only submits to the processing page. Example:

<div style="width:800px;text-align:LEFT;margin:0 auto;padding-bottom:5px;">
  <input type="submit" value="<-- Back to Parts A-C" style="border:none;background-color:transparent;color:blue;text-decoration:underline">
</div>
<div style="width:800px;text-align:right;margin:0 auto;padding-bottom:5px;">
  <input type="submit" value="Save Report" /></form></p>
</div>

I'm trying to find a way for Page 1 to be able to receive the text box inputs from page 2. Any suggestions?

I solved a similar problem by putting the values that the user enters in session immediately when they submit any form, even if it's not the final form before saving to the database.

I've never used php, but you should be able to write some code like this:

<input type='text' name='txtName', value={if name in session, print name here, otherwise ""} />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM