Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 30DBE4759FA for ; Wed, 29 May 2002 11:03:00 -0400 (EDT) Received: from enterprise.centliq.com (adsl-65-71-224-185.dsl.rcsntx.swbell.net [65.71.224.185]) by postgresql.org (Postfix) with ESMTP id 613A5475B19 for ; Wed, 29 May 2002 11:02:58 -0400 (EDT) Received: from centennialwines.com (unknown [192.168.1.2]) by enterprise.centliq.com (Postfix) with ESMTP id 70640FF009; Wed, 29 May 2002 09:53:23 -0500 (CDT) Message-ID: <3CF4EEEA.5040006@centennialwines.com> Date: Wed, 29 May 2002 10:08:26 -0500 From: "David C. Brown" User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0rc2) Gecko/20020510 X-Accept-Language: en-us, en MIME-Version: 1.0 To: jules.alberts@arbodienst-limburg.nl Cc: pgsql-php@postgresql.org Subject: Re: variable visibility when using References: <200205291453.g4TErRFP005339@artemis.cuci.nl> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200205/107 X-Sequence-Number: 1239 How about using a session? session_start() $password="fubar"; session_register("password"); then on the next page (sub.php) call session_start(); again and $password will become visable. see http://www.php.net/manual/en/function.session-start.php Dave Jules Alberts wrote: >hello world, > >sorry if this is off topic, but the question arose when i was buidling >a test system with PHP4 / postgresql. > >i want a user to enter a user ID and password in order to make a non- >permanent database connection. so the application (that consistes of >several PHP and HTML files) should remember the values in variables. > >a logical approach seemed to be global variables, however, this doesn't >work when new pages are generated. in this small example: > > // this is file main.php > echo ""; > $password="fubar"; > echo "password is: \"$password\"
"; > echo "sub"; > echo ""; > ?> > > // this is file sub.php > echo ""; > global $password; // doesn't work > echo "password is: \"$password\"
"; > echo ""; > ?> > >the variable $password is not visible in sub.php. i guess this is >because the href link creates a new page, a fresh start. still i want >$password to be visible in sub.php. what is a good, safe way to do >this? setting serverside environment variables sounds dangerous. and i >would like to avoid cookies (unless it's the only way). i thought about >include_once(), but you can't call that from a link. or can you? > >how is this normally done? TIA for any tips! > > >