array carrying from one php page to another

array carrying from one php page to another

am 08.12.2005 07:33:52 von Eternity Records Webmaster

I have an array $journal that I want to carry from a page (where it was
created) to another page (a popup that shows the variables contents). Is
this automatically available? or do I have to do something special to php??

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

Re: array carrying from one php page to another

am 08.12.2005 07:59:38 von Chris Shiflett

Curt Zirzow wrote:
> > $array = array('my', 'list', 'of', 'stuff');
> $_SESSION['array_for_popup'] = $array;
> ?>
>
> And in the code that is called in the popup:
>
> > if(!isset($_SESSION['array_for_popup']) {
> die('you should not be here anyway, only on a popup is this allowed');
> }
>
> $array = $_SESSION['array_for_popup'];
> // .. do your magic.
>
> // optionally clean things up. so the session var is removed.
> unset($_SESSION['array_for_popup']);
> ?>

Don't forget session_start(). :-)

(You might have session.auto_start enabled, but it's not by default.)

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

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

Re: array carrying from one php page to another

am 08.12.2005 08:00:37 von Curt Zirzow

On Thu, Dec 08, 2005 at 01:33:52AM -0500, Eternity Records Webmaster wrote:
> I have an array $journal that I want to carry from a page (where it was
> created) to another page (a popup that shows the variables contents). Is
> this automatically available? or do I have to do something special to php??

It can be sort of automatically:

$array = array('my', 'list', 'of', 'stuff');
$_SESSION['array_for_popup'] = $array;
?>

And in the code that is called in the popup:

if(!isset($_SESSION['array_for_popup']) {
die('you should not be here anyway, only on a popup is this allowed');
}

$array = $_SESSION['array_for_popup'];
// .. do your magic.

// optionally clean things up. so the session var is removed.
unset($_SESSION['array_for_popup']);
?>

Curt.
--
cat .signature: No such file or directory

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

Re: array carrying from one php page to another

am 08.12.2005 08:39:46 von Zack Bloom

------=_Part_9954_11792862.1134027586877
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

you could just pass in in the address, eg:
www.example.com?var1=3D$var1&var2=3D$var2

to get them use $_REQUEST['var1']

to pass an array you could use serialize($var1) and unserialize($var1)


On 12/8/05, Chris Shiflett wrote:
>
> Curt Zirzow wrote:
> > > > $array =3D array('my', 'list', 'of', 'stuff');
> > $_SESSION['array_for_popup'] =3D $array;
> > ?>
> >
> > And in the code that is called in the popup:
> >
> > > > if(!isset($_SESSION['array_for_popup']) {
> > die('you should not be here anyway, only on a popup is this allowed')=
;
> > }
> >
> > $array =3D $_SESSION['array_for_popup'];
> > // .. do your magic.
> >
> > // optionally clean things up. so the session var is removed.
> > unset($_SESSION['array_for_popup']);
> > ?>
>
> Don't forget session_start(). :-)
>
> (You might have session.auto_start enabled, but it's not by default.)
>
> Chris
>
> --
> Chris Shiflett
> Brain Bulb, The PHP Consultancy
> http://brainbulb.com/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

------=_Part_9954_11792862.1134027586877--

Re: array carrying from one php page to another

am 08.12.2005 08:59:12 von Curt Zirzow

On Thu, Dec 08, 2005 at 02:39:46AM -0500, Zack Bloom wrote:
> you could just pass in in the address, eg:
> www.example.com?var1=$var1&var2=$var2
>
> to get them use $_REQUEST['var1']
>
> to pass an array you could use serialize($var1) and unserialize($var1)

Or just use http_build_query() (php5 only)

Curt.
--
cat .signature: No such file or directory

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

Re: array carrying from one php page to another

am 08.12.2005 17:46:38 von Sandy Keathley

> I have an array $journal that I want to carry from a page (where it was
> created) to another page (a popup that shows the variables contents). Is
> this automatically available? or do I have to do something special to php??

One way:
$serArray = serialize($array);



At other end:

$array = unserialize($_POST['serArray']);

======================================

OR

session_start();
..
..
..
$_SESSION['array'] = serialize($array);


At other end:

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

If you change or repopulate the array, use the same session name, or, to be
safe,

$_SESSION['array'] = null;

before repopulating the session.

Make sure session_start() is on every page that needs access to the session
variable, including the popup.


SK



************************************************************
WebDesigns Internet Consulting
E-commerce Solutions
Application Development

Sandy Keathley
Zend Certified Engineer
sandy@KeathleyWebs.com
972-569-8464

http://www.KeathleyWebs.com/
************************************************************

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

Re: array carrying from one php page to another

am 09.12.2005 00:43:42 von Ligaya Turmelle

--------------050102090809030803020102
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Session variable or hidden field maybe

Eternity Records Webmaster wrote:
> I have an array $journal that I want to carry from a page (where it was
> created) to another page (a popup that shows the variables contents). Is
> this automatically available? or do I have to do something special to php??
>

--

life is a game... so have fun.


--------------050102090809030803020102
Content-Type: text/plain; charset=us-ascii

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

RE: Re: array carrying from one php page to another

am 09.12.2005 12:51:42 von M.Ford

On 08 December 2005 16:47, Sandy Keathley wrote:

> > I have an array $journal that I want to carry from a page (where it
> > was created) to another page (a popup that shows the variables
> > contents). Is this automatically available? or do I have to do
> > something special to php??=20
>=20
> One way:
> $serArray =3D serialize($array);
>=20
> ">
>=20
> At other end:
>=20
> $array =3D unserialize($_POST['serArray']);
>=20
> ==================== =====
==============
>=20
> OR
>=20
> session_start();
> .
> .
> .
> $_SESSION['array'] =3D serialize($array);

Why on earth would you want to serialize an array you're adding to the sess=
ion? That's just a terrible waste of good machine cycles.

> Zend Certified Engineer

Really?? I think I just lost all faith in that "qualification".

Cheers!

Mike

------------------------------------------------------------ ---------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211=20


To view the terms under which this email is distributed, please go to http:=
//disclaimer.leedsmet.ac.uk/email.htm

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

Re: Re: array carrying from one php page to another

am 09.12.2005 14:59:36 von Jochem Maas

Ford, Mike wrote:
> On 08 December 2005 16:47, Sandy Keathley wrote:
>

....

>>.
>>.
>>$_SESSION['array'] = serialize($array);
>
>
> Why on earth would you want to serialize an array you're adding to the session? That's just a terrible waste of good machine cycles.

terrible, very. too many hits to the server and this little faux pas will
really bring the CPU to its knees


Sandy, anything you stick in $_SESSION is automatically serialized by php when the
session is closed (or the request is complete - i.e. during script shutdown) .. which
means you don't have to do it!

>
>
>>Zend Certified Engineer
>
>
> Really?? I think I just lost all faith in that "qualification".

state provided 'educational' services are nothing more than highly
sophisticated indoctrination systems ... Zend is upfront about the
reasons for having a 'qualification' system but is Leeds Met?

Or lets look at that a totally different way ... Leeds Met is a
very prejudiced, dogmatic operation with a higgly judgemental cultural
background that is incapable of stimulating or encouraging open-minded,
critical thinking. I know this because you work there and you one comment
about losing faith tells me everything there is to know about Leeds Met and
all the people who work/study there; just like you are able to
judge the Zend Exam based on one slight mistake from one particular person who
advertises herself as having passed said exam....

over&out

>
> Cheers!
>
> Mike
>
> ------------------------------------------------------------ ---------
> Mike Ford, Electronic Information Services Adviser,
> Learning Support Services, Learning & Information Services,
> JG125, James Graham Building, Leeds Metropolitan University,
> Headingley Campus, LEEDS, LS6 3QS, United Kingdom
> Email: m.ford@leedsmet.ac.uk
> Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
>
>
> To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
>

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