I am writing a small application to track a weekly league participation.
I have a login area where a user can log in and enter all of the member
information, weekly participation, and results.
The way that I am thinking of it is like this:
1. user logs in
2. click link to enter information
3. user is then shown a list of all available members, with check boxes next
to their names, check the necessary participants. There is also an ADD NEW
yes/no radio button selection
if the user select yes on the ADD NEW:
4. they are sent to an addmember form where they can enter member name, addr,
email, phone, etc... they have the option to SAVE and ADD NEW or to simply SAVE
and CONTINUE. When submitted, each new member gets added to the members table
OTHERWISE
5. once all new members have been added, user is sent to a form where they can
enter results. this page will have a series of dropdown lists populated with
the names of members (gotten from step 3 & 4). Once submitted, the database is
updated
HERE IS THE QUESTION: WHAT IS BEST PRACTICE? SHOULD I BE PASSING THESE
VARIABLES FROM PAGE TO PAGE VIA FORM VARIABLES OR SESSION VARIABLES...OR USING
SOMETHING ELSE????
ANY SUGGESTIONS
THANKS
SMB
Dan Bracuk - 30 Dec 2005 19:54 GMT
I like session variables myself.
Just out of curiousity, how are you going to preserve the checkmarks of existing members if the user proceeds to add new ones?
stephenmbell - 30 Dec 2005 20:15 GMT
The value of the checkbox is the id of that member, so when the form is
submitted, a comma delimited string will be passed and somehow stored (session
or form)
If they ADD NEW, either through form or session variables, I will create a new
variable to store a comma delimted string of each new player added (havent
decided if i will use @@identity, or membercode (a unique string generated each
time a member is added) -
if it is by the member code, i will create a list of all of the new players
added, then query the db to get their memberids and concatenate the result set
on to the list from the checkboxes.
if it is by using @@identity, i will get the id of the last inserted record
after i insert members, then i will just concatenate those values on to the
value from teh checkboxes
James74 - 30 Dec 2005 20:09 GMT
Generally, I use sessions if I need to pass structs or arrays around (if
passing multiple fields for multiple people). From my understanding of what
your trying to do, I think you would want to do this in the first example. The
add another person button would direct your code to grab the other member
information, store it in a session array and go to the add person page.
After you added the person, you go back to your member page where you would
populate the fields already entered with the information in the session array.
The continue/submit button on the member page would add the information to the
database.
However, it may be clearer to the end user to go with your second option
because of simplicity. The user has two clear options: add members, or update
member information.
As for best practices, it really depends on what your trying to do. I try to
not pass around form variables to other forms because the code can get messy.
Hope this helps