Re: Passing vars between pages using Apache on my laptop
| From: | Gabriel de Rezende e Lamounier | Date: | Mon, 12 Apr 2004 17:05:04 +0000 |
| Subject: | Re: Passing vars between pages using Apache on my laptop | ||
| Groups: | php.install | ||
| Request: | Send a blank email to php-install+get-13228@lists.php.net to get a copy of this message | ||
Em Sex 02 Abr 2004 23:10, Scott E Foulk escreveu:
> Aloha,
> I am using Apache on my laptop to emulate my online database and
> site and wondering about 2 things:
>
> 1 - I'm not able to pass variables between pages in PHP
> e.g. On page1.php I have a field named in_company, which, on the
> website my client is hosted from passes into the next page as $in_company.
> But on my self-configured Apache/PHP/MySQL laptop setup, the variables
> come up as undefined on the follwing page.
your original server must have been configured with "register_globals=0n" on
php.ini and on you laptop it must be set "register_globals=Off" wich is the
defalt.
setting register_globals on enables you to pass in_company as $in_company, but
if it's set off trying to access the value of in_company directly as
$in_company will fail. it's because when register_globals is on it
automatically assign the value of a passed variable to a variable of the same
name in the php script.
> The queries with MySQL work
> nicely, but not without variable passing. I don't like to append on to
> the URL as some vars I like to keep low profile.
> e.g.
>
> http://www.mysite.com?var_0=5&var_1=sometext&var_2=morestuff&etc=more
>
if register_globals is off, this assignment dosn't happen automatically, so
you must first do:
$in_company = $_GET['in_comany']
or
$in_company = $_POST['in_company']
depending on the method you're using.
remember that relying on register_globals been set as on is not a good
practice.
gabriel