RE: [PHP] Help for passing variable to all pages
| From: | WG4- Cook, Janet | Date: | Wed, 20 Feb 2002 23:08:51 +0000 |
| Subject: | RE: [PHP] Help for passing variable to all pages | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-85632@lists.php.net to get a copy of this message | ||
Thanks for the suggestion but it made no difference!
I am still getting nothing through
I think its something to do with the "test link" bit - what actually should
go in here - how does it relate this to all links?
Janet
-----Original Message-----
From: Rick Emery [mailto:remery@excel.com]
Sent: Thursday, 21 February 2002 2:04
To: 'WG4- Cook, Janet'; PHP List
Subject: RE: [PHP] Help for passing variable to all pages
change:
<a href="welcome.php3?dbcnxid=<?php echo("$dbcnx"); ?>test link</a>
to:
<a href=<?php print "\"welcome.php3?dbcnxid=$dbcnx\""; ?>>test
link</a>
-----Original Message-----
From: WG4- Cook, Janet [mailto:JCook@ICO.NEC.COM.AU]
Sent: Tuesday, February 19, 2002 5:30 PM
To: PHP List
Subject: [PHP] Help for passing variable to all pages
Hi All,
I am new to PHP and learning as I go by reading many of the tutorials
around. I have however come up against a problem that I can't seem to solve
of find any other references to.
I need to make some information available to every page and one of the
series of articles by Kevin Yank which talks about PHP and MySql seemed to
suggest how to do exactly what I wanted but I can't get it to work. His
suggestion was to do something like
<A HREF="newpage.php?name=<?php echo($myvar); ?>" A link </A>
I think my problem is in the ...A LINK.. bit - what exactly should go here?
I tried some code to see if it worked and this is what I did:
in login.html
<html>
<head>
<title>DMS Login</title>
<?php
$dbcnx=@mysql_connect("localhost","DMS","");
echo ( "<P> Connection established on $dbcnx</P>");
if (!$dbcnx) {
echo( "<P>Unable to connect to MySql Server at this time.</P>"};
exit();
}
if (! @mysql_connect_db("DMS", $dbcnx) ) {
echo( "<P>Unable to connect to DMS database at this time.</P>"};
exit();
}
?>
<a href="welcome.php3?dbcnxid=<?php echo("$dbcnx"); ?>test link</a>
<FORM ACTION="welcome.php3" METHOD=GET>
First name: <INPUT TYPE=TEXT NAME="firstname"><BR>
Last Name: <INPUT TYPE=TEXT NAME="lastname">
<INPUT TYPE=SUBMIT VALUE="GO">
</FORM>
<br>
<br>
In the welcome.php3 file I have
<HTML>
<HEAD>
<TITLE>Today's Date</TITLE>
</HEAD>
<BODY>
<P>Today's date (according to this server)
<?php
echo( date("l, F dS Y.") );
echo ("Welcome to our web site $firstname $lastname $dbcnxid ");
echo (" $dbcnxid");
echo (" $QUERY_STRING");
?>
</BODY>
</HTML>
What I get is on login page - the text test link in blue (i.e. a
link?) and the login prompts.
On the welcome page I get the firstname and lastname ok, but the other
parameter is not in the $QUERY_STRING
Does anyone have any ideas as to what I am doing wrong?
Maybe there is a better way to have some information, that will be retrieved
from the DB available to all pages in the session. We are not actually
going to have all the users with logins to the DB - but have our own
internal table of users, password and rights information, thus the userid
form this table needs to be available to all pages.
Many Thanks in advance for your help
Janet Cook
Software Engineer
IT &CM
CSDD
NEC Australia Pty Ltd
Ph +613 9264 3813
Email: jcook@ico.nec.com.au
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php