Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-10-2012, 11:03 PM   PM User | #16
mathruD
New Coder

 
Join Date: Apr 2011
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
mathruD is an unknown quantity at this point
double post
mathruD is offline   Reply With Quote
Old 07-10-2012, 11:27 PM   PM User | #17
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
Well, the obvious thing is... don't store into the session is your POST has no values, just like you wouldn't try to send an email from a form if the form had no data submitted. If you want your session variable not to contain something blank, if $_POST isn't set, don't store new values.

The sessions are working fine, but you're not working with them properly.
Keleth is offline   Reply With Quote
Old 07-11-2012, 12:05 AM   PM User | #18
mathruD
New Coder

 
Join Date: Apr 2011
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
mathruD is an unknown quantity at this point
Should I just do what you are saying, and check if the $_POST field is empty and then set the values into an array. That way I could avoid SESSIONS entirely?
mathruD is offline   Reply With Quote
Old 07-11-2012, 02:52 PM   PM User | #19
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
Well, if you just store them into an array, and not a session, you won't be able to move them between pages...

I'm not really sure what you're trying to do anymore.
Keleth is offline   Reply With Quote
Old 07-12-2012, 07:49 PM   PM User | #20
mathruD
New Coder

 
Join Date: Apr 2011
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
mathruD is an unknown quantity at this point
There are two pages (let's say page1 and page2).

The first page contains numerous photos. Each photo contains a checkbox. If that checkbox is checked, a div opens revealing multiple select menus for choosing a number of photo prints at each size. It would looks something like this when the div opened:

4"x6" [select a quanitity]
5"x7" [select a quanitity]
8"x10" [select a quanitity]
....

So the user checks of all the photos that they want, and then select a quantity of each size for those specific photos. The user then presses a submit button, which leads us to page2.

Page2 is used to process this info. All of the info from the photo form is then echoed for the user to review. So it might look something like this:

Review your order:
Photo 1 - (2) - 4"x6" prints, (4) - 5"x7" prints
Photo 2 - (3) - 4"x6" prints, (1) - 8"x10" print
........

All of that works fine. The photo selections are echoed perfectly.

Page2 also contains a simple form to take in name, email, etc. The form also contains a hidden input field to pass along the order. At this point, if the page is refreshed, or if the user attempts to send the form, but gets errors in form validation, all of the values disappear. That is because the variables were being set based on the POST values from the previous page. So, of course, if the page is refreshed for any reason, the POST values no longer exist. So I started using SESSIONS to set all of the values so that they would still show up, even on refresh. Everything is working fine now, although you told me I was using SESSIONS improperly. I'm not quite sure how I'm using them improperly, though.
mathruD is offline   Reply With Quote
Reply

Bookmarks

Tags
array, form, loop, post, refresh

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:45 AM.


Advertisement
Log in to turn off these ads.