Page 1 of 1

Passing Data with Sessions

Posted: Mon May 23, 2011 1:58 pm
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);

Re: Passing Data with Sessions

Posted: Mon May 23, 2011 1:59 pm
by bowersbros
is it sensitive data? eg passwords? CC details?

Re: Passing Data with Sessions

Posted: Mon May 23, 2011 2:02 pm
by unemployment
bowersbros wrote:is it sensitive data? eg passwords? CC details?
Nope. Not sensitive.

Re: Passing Data with Sessions

Posted: Mon May 23, 2011 2:03 pm
by bowersbros
you could send it via $_GET

its easier than sessions.

Re: Passing Data with Sessions

Posted: Mon May 23, 2011 2:06 pm
by jacek
adding a hidden form input may also be easier.
<input type="hidden" name="suggestions" value="<?php echo htmlentities($suggested_companies); ?>" />
for example.

Re: Passing Data with Sessions

Posted: Mon May 23, 2011 2:17 pm
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.

Re: Passing Data with Sessions

Posted: Mon May 23, 2011 2:33 pm
by jacek
unemployment wrote:I probably don't even need sessions, gets or hidden inputs, right?
Doesn't sound like it ;)