 |
| 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
|
|
|
|

January 5th, 2005, 11:57 AM
|
|
Registered User
|
|
Join Date: Jan 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

January 5th, 2005, 11:58 AM
|
|
Registered User
|
|
Join Date: Jan 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
|

January 5th, 2005, 03:45 PM
|
|
Authorized User
|
|
Join Date: Jan 2005
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

January 5th, 2005, 05:48 PM
|
|
Registered User
|
|
Join Date: Jan 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

January 5th, 2005, 07:46 PM
|
|
Authorized User
|
|
Join Date: Jan 2005
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Glad it worked.
|
|
 |