Passing Data with Sessions

Ask about a PHP problem here.
Post Reply
unemployment
Posts: 165
Joined: Fri May 06, 2011 5:02 pm

Passing Data with Sessions

Post by unemployment »

How do I pass data entered in by the user from one page to the next? I imagine I would use sessions for this, but I don't really know how to do it.

How do I say... take the data the user typed into the company name field and then run it through this function..
$suggested_companies = fetch_company_by_name($name);
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

Re: Passing Data with Sessions

Post by bowersbros »

is it sensitive data? eg passwords? CC details?
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
unemployment
Posts: 165
Joined: Fri May 06, 2011 5:02 pm

Re: Passing Data with Sessions

Post by unemployment »

bowersbros wrote:is it sensitive data? eg passwords? CC details?
Nope. Not sensitive.
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

Re: Passing Data with Sessions

Post by bowersbros »

you could send it via $_GET

its easier than sessions.
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Passing Data with Sessions

Post by jacek »

adding a hidden form input may also be easier.
<input type="hidden" name="suggestions" value="<?php echo htmlentities($suggested_companies); ?>" />
for example.
Image
unemployment
Posts: 165
Joined: Fri May 06, 2011 5:02 pm

Re: Passing Data with Sessions

Post by unemployment »

I guess the real question is... do I even need to manipulate data this way. If a user is creating a company via a form and they enter in the company name, hit submit and that name matches a name in MySQL I want to display the companies that already exist with that name.

This does not bring the user to a new page, but just replaces the current form with suggested companies. I probably don't even need sessions, gets or hidden inputs, right?


UPDATE: Nevermind. Looks like I just need to create a different variable.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Passing Data with Sessions

Post by jacek »

unemployment wrote:I probably don't even need sessions, gets or hidden inputs, right?
Doesn't sound like it ;)
Image
Post Reply