Re: [PHP] Sessions and Forms

2002-06-08 Thread Jason Wong

On Saturday 08 June 2002 14:39, Greg Macek wrote:
 What is the best/recommended method of saving form data into session
 variables? Currently only have to deal with regular text input,
 checkboxes and radio buttons (no multiple selects for now). Any sample
 code someone could throw up on the list? I've only recently begun
 working with sessions, but I'm interested to see what I can do with
 them. Any sort of direction on this would be appreciated. Thanks!

What I do is try to put all the form elements into a single array. That way 
you'll only have a single variable to worry about.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Future looks spotty.  You will spill soup in late evening.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Sessions and Forms

2002-06-08 Thread Greg Macek

Ok, I'll have to try that on my next project. Unfortunately these forms were 
written by another developer and there too many variables to rename to make an 
array and not enough time on the project :-)  But for next time.

I've seen many examples of assigning values to session variables w/o forms on 
the list and online. Now should I look to set those values on the next page in 
the sequence of forms that the user is entering?

page1.php
?php
session_start();
*** session_register(test_var);*** // Is this ok?
?
form action=page2.php
input type=text name=test_var/input
input type=submit
/form

page2.php
?php
session_start();
*** $_SESSION[test_var] = $test_var;  *** // Or is this ok?
// or $HTTP_SESSION_VARS[test_var] = $test_var on =4.0.6
?
... (rest of page here)

Which of the two lines is more failsafe in terms of working every time?

Jason Wong wrote:
 On Saturday 08 June 2002 14:39, Greg Macek wrote:
 
What is the best/recommended method of saving form data into session
variables? Currently only have to deal with regular text input,
checkboxes and radio buttons (no multiple selects for now). Any sample
code someone could throw up on the list? I've only recently begun
working with sessions, but I'm interested to see what I can do with
them. Any sort of direction on this would be appreciated. Thanks!
 
 
 What I do is try to put all the form elements into a single array. That way 
 you'll only have a single variable to worry about.
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Sessions and Forms

2002-06-08 Thread Nick Wilson

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


* and then Greg Macek declared
 Ok, I'll have to try that on my next project. Unfortunately these forms 
 were written by another developer and there too many variables to rename 

How about something like this:

foreach($HTTP_POST_VARS as $key = $val) {
$myFormData['$key']=$val;
}

Then you just register the $myFormData and it will be available to you
whenever you need it.

- -- 
Nick Wilson //  www.explodingnet.com



-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)

iD8DBQE9AbEvHpvrrTa6L5oRAirPAJ9HylqSk9NBsNsTjjRZZ2fBHN3K3QCdGzdS
t6yXIWhWu76VxfGkpQp6JdI=
=uZMW
-END PGP SIGNATURE-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Sessions and Forms

2002-06-08 Thread Nick Wilson

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


* and then Nick Wilson declared
 How about something like this:
 
 foreach($HTTP_POST_VARS as $key = $val) {
 $myFormData['$key']=$val;
 }

Actually that may be a little redundent. You may well get away with:

$myFormData=$HTTP_POST_VARS;
- -- 
Nick Wilson //  www.explodingnet.com



-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)

iD8DBQE9AbHmHpvrrTa6L5oRAnYDAJ97cMzKPwdp42y+G7KiixEAavdFYACdEOlP
bBSkoamAv10hHnDAmrVfiBk=
=NHHQ
-END PGP SIGNATURE-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php