Re: Storing values between multiple page forms

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Matty Sarro wrote:
Yeah, I'm working on this with the hopes of it turning into a full module
for a larger project I'm working on... but I'm still a bit of a noob :)
Thanks for the assistance guys!

On Tue, Mar 11, 2008 at 11:48 AM, Daniel Brown <parasane@xxxxxxxxx> wrote:

On Tue, Mar 11, 2008 at 11:11 AM, Matty Sarro <msarro@xxxxxxxxx> wrote:
Greets all!
 I am working on a minor project for work for entering inventory
information
 for servers we ship out.

 Here is my plan:
 First page -
 Get client name, number of servers, and find number of miscellaneous
 equipment(s) being shipped (UPS's, monitors, etc)
[snip!]
 I'm still planning this out... my major concern is how would I maintain
 values between pages?
<?php
session_start();
$_SESSION['value'] = $your_sanitized_value_from_POST;
$_SESSION['value2'] = $your_second_sanitized_value;
echo "<pre />\n";
print_r($_SESSION);
echo "</pre>\n";
?>

   RTFM: http://php.net/session

   Keep in mind, it'll only work on the same server and same domain.
Otherwise, you may want to look into using wildcard cookies.

--
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>



If you are going to follow Daniel's example, since you could potentially be working with more then one server on any given order, you might want to look at using a multi-dimensional array to store your values in.

$_SESSION['order_info'] = array();

$_SESSION['order_info']['customer_data'] = array();

$_SESSION['order_info']['customer_data']['name'] = '';

$contact_data                 = array();
$contact_data['type']         = 'billing';
$contact_data['address']      = '123 Someplace Ave';
$contact_data['city']         = 'New York';
$contact_data['state']        = 'NY';
$contact_data['phone_number'] = '2134526523';

$_SESSION['order_info']['customer_data']['contact_data'][0] = $contact_data;

$contact_data                 = array();
$contact_data['address']      = 'shipping';
$contact_data['city']         = '321 Somewhere Ave';
$contact_data['state']        = 'New York';
$contact_data['state']        = 'NY';
$contact_data['phone_number'] = '2134526523';

$_SESSION['order_info']['customer_data']['contact_data'][1] = $contact_data;

$server['make']  = 'Dell';
$server['model'] = 'Power Edge 2400';
$server['ram']   = '2gig';
$server['hd']    = '6x18g Seagate U320 SCSI';
$server['video'] = '64 ATI';

$_SESSION['order_info']['servers'][0]          = $server;

$server['make']  = 'Dell';
$server['model'] = 'Power Edge 2600';
$server['ram']   = '2gig';
$server['hd']    = '3x36g Seagate U320 SCSI';
$server['video'] = '64 ATI';

$_SESSION['order_info']['servers'][1]          = $server;


As you might have guessed, I like arrays.

I would actually go as far as making arrays out of the ram, hd, etc... data. This would allow me to have detailed information about each section/option.

Hope this helps

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux