Passing String

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Passing String

Post by Ree »

I need to pass a string (a message, to be specific) from one .php to another. $_GET obviously won't work well. One of the ways is using $_SESSION (but maybe it's a bit too much just for that, having in mind I won't need to pass/save any other data, just a string. Not sure on this, although using $_SESSION would be pretty easy and comfy). I thought maybe there's a way to $_POST the string to the page where I need it via PHP (that is, not manually pressing a button using HTML form)? If this way exists, which of the two (the latter or $_SESSION) eats up more resources?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$_SESSION is far easier to do than hidden posting.
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Post by Ree »

Could you provide an example of how this 'hidden' posting is done? I assume, you recommend using $_SESSION in my case, right?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

hidden posting involves using cURL. Which is not the easiest to example, but I have posted curl examples in the past.

yes, I would suggest using sessions, especially if you want to end up on this second page. The hidden posting will do nothing on the current page. You won't jump anywhere, or do anything unless otherwise instructed..
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Well, the thing is, if you used hidden posting, the page you posted the variable to would have no idea when the user comes around... so you'd end up building your own session handling structure. There's nothing inherently wrong with this (especially for distributed environments), but you should stick with $_SESSION
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it wouldn't have data, unless the script doing the hidden posting displayed the results of said hidden post. ;)
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Post by Ree »

Thanks for you replies ;)
Post Reply