Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
| Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 5th, 2005, 11:57 AM
Registered User
 
Join Date: Jan 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Some variable dissapear after goin tru 10 pages


I had a question:

We made a small website in PHP. The website was made for the consultants. They use the website to make offers and bills.

I use sessions in the forms. The website consists of 10 webpages.
Each form passes variables and pass it trough the next form. Every page has a form. The last pages sums up every variable and will show the offers. With javascript it gives a print command. It's like a step for step method website. The thing is: when I got to step 3, and I return back (Backbutton) to the first page (Step1): everything which was filled in step 2 is dissapeard. How can I make it, so that it remembers everything from step 2?

PS: I don't use the database to write things in it with the php code only reading things from the database.

2nd problem: In some forms I use checkboxes dropdownboxes etc. When I am at step 6, and I go back to step 5, The selected value from the dropdownboxes etc. resets completely. How can i make it, so the dropdownboxes etc. remembers the chosen value's from the user?


My last question:

I made a webpage, with a dropdownbox in it. It should pass the value from the dropdownbox to the next page (last page) When I go to the next page, nothing can be seen. But if I push the back button and refill the data, it will pass trough succesfully. Why does this happen?

Please help me with my problems. Please guide me and point me to the right sollution



 
Old January 5th, 2005, 11:58 AM
Registered User
 
Join Date: Jan 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Monkeycoder


I had a question:

We made a small website in PHP. The website was made for the consultants. They use the website to make offers and bills.

I use sessions in the forms. The website consists of 10 webpages.
Each form passes variables and pass it trough the next form. Every page has a form. The last pages sums up every variable and will show the offers. With javascript it gives a print command. It's like a step for step method website. The thing is: when I got to step 3, and I return back (Backbutton) to the first page (Step1): everything which was filled in step 2 is dissapeard. How can I make it, so that it remembers everything from step 2?

PS: I don't use the database to write things in it with the php code only reading things from the database.

2nd problem: In some forms I use checkboxes dropdownboxes etc. When I am at step 6, and I go back to step 5, The selected value from the dropdownboxes etc. resets completely. How can i make it, so the dropdownboxes etc. remembers the chosen value's from the user?


My last question:

I made a webpage, with a dropdownbox in it. It should pass the value from the dropdownbox to the next page (last page) When I go to the next page, nothing can be seen. But if I push the back button and refill the data, it will pass trough succesfully and will be shown. Why does this happen?

Please help me with my problems. Please guide me and point me to the right sollution



 
Old January 5th, 2005, 03:45 PM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Please post your codes to help us see what your problem is, but you can get started anyway:


Whenever you pass a form to the next page, save the $_POST data to session variables. Here is an example of the second page:

<?php
session_start(); //YOU NEED TO HAVE THIS ON ALL OF YOUR PAGES THAT YOU WANT TO RETAIN THE VALUES IN THE SESSIONS.
header("cache-control: private");



$_SESSION['somename'] = $_POST['previousformfieldname'];
$_SESSION['username'] = $_POST['username'];
..
..

.
..


Do this for all of your field. Of course there are easier, better ways to do this, such as using foreach and looping through the $_POST array. But whatever method you use, you need to this step.

After you do this, in your first page (where the original form was) and on all form fields where you want to have the form field retain its value do this:

//this will put the value of that particular session variable in that text field. the @ is there just in case the session variable was not defined.
<input type="text" name"username" id="username" value="<?php echo @$_SESSION[username]; ?>">

Hope this helps.


 
Old January 5th, 2005, 05:48 PM
Registered User
 
Join Date: Jan 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks! Your comment solved my problem.

The thing is, my data wasn't dissplayed at the screen (at once, so I needed to press f5 to display it properly), because I used:

<?php echo"$Username" ?>

When I used

<?php echo @$_SESSION[Username]; ?>

everything was shown perfectly :)

Thanks again

 
Old January 5th, 2005, 07:46 PM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Glad it worked.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Master Pages, Content Pages and CSS carliviris Visual Studio 2005 0 January 8th, 2008 05:56 PM
ASSIGNING A JAVA SCRIPT VARIABLE TO A XSL VARIABLE SOMANATHAN10 XSLT 1 February 21st, 2007 04:26 AM
Dissapear mouse and use key to navigate on web pag karib JSP Basics 0 July 2nd, 2004 12:53 AM
Web pages constructing: I-mode(mobile) pages karib Dreamweaver (all versions) 3 June 6th, 2004 09:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.