RE: [PHP-DB] Sending variables between PHP pages

From: Date: Fri, 04 Jan 2002 13:42:55 +0000
Subject: RE: [PHP-DB] Sending variables between PHP pages
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-15381@lists.php.net to get a copy of this message
> -----Original Message----- > From: markus|lervik [mailto:markus.lervik@vaasa.fi] > Sent: Friday, January 04, 2002 1:29 PM > > > > Example: > > > > <?php > > # Include the file containing general variables/constants/funstions > > require ("general.inc"); > > > > # Open a connection to MySQL using variables from general.inc > > $link = mysql_connect ($host, $username, $password); > > ?> > > > Yes, but then we come across the other problem, namely, if you click a > submit button that has a ACTION="<?php echo $PHP_SELF?>", technically the > script ends when it reloads the page, and therefore also forgets $host, > $username and $password, so I'd probably still have to somehow > register the > variables, ie. using session_register, no? As long as you start all php files in your application by including the "general.inc" file, you will never lose these variables. The file "general.inc" may look like this: <?php $host = "127.0.0.1"; $username = "john"; $password = "secret"; ?> Just a word of caution.... Make sure that the file "general.inc" is NOT readable by the web server. Otherwise, it would be very easy to do a http://your.host/general.inc to reveal your database password. Regards, -Bjarte-

« previous php.db (#15381) next »