View Single Post

  #3 (permalink)  
Old 11-13-2003
David T-G
 
Posts: n/a
Default Re: [PHP] Multiple values in a form option field

Jeff, et al --

...and then Jeff McKeon said...
%
% I have a php page that has a web form on it.

Yay! Yippee! That's great!

Oh, that's not the substantive body of your note? :-)


%
% I do a query to populate the options in a drop down box in the form.
%
...
% So when the user selects an email addres from the drop down box, the
% userID is stored and later writen to a database.

Right.


%
% What I now need to do is store not only the userID but the email address

OK.


% as well. Is there a way using a form to store 2 values using one drop

Well, yes and no. You can store only one value in a field, but that
value can be anything you want it to be.


% down box? So basically I want to store the userID and the Email address
% to a variable in the form so that both may be written to different
% fields in the database later.

If I were going to do this (and I've done a bit like it), I would first
make an array of everything to be sent, then serialize it, and finally
base64_encode it and use that as the value. When you get it on the other
side, just decode and then unserialize and you have your array back to
use as you wish. This works for large numbers of vars as well as just a
few.


%
% Jeff


HTH & HAND

:-D
--
David T-G * There is too much animal courage in
(play) davidtg@justpickone.org * society and not sufficient moral courage.
(work) davidtgwork@justpickone.org -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE/s/qXGb7uCXufRwARAmd+AKCOTKgV8Zy7a+UpOo2NXZHIHbPKtACf baqR
G/fnaBJT7gweC1FMNyMv/Vg=
=69oJ
-----END PGP SIGNATURE-----

Reply With Quote