Re: variable visibility when using <a href></a>

From: "David C(dot) Brown" <dbrown(at)centennialwines(dot)com>
To: jules(dot)alberts(at)arbodienst-limburg(dot)nl
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: variable visibility when using <a href></a>
Date: 2002-05-29 15:08:26
Message-ID: 3CF4EEEA.5040006@centennialwines.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

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
> <?php
> echo "<html><body>";
> $password="fubar";
> echo "password is: \"$password\"<br>";
> echo "<a href='sub.php'>sub</a>";
> echo "</body></html>";
> ?>
>
> // this is file sub.php
> <?php
> echo "<html><body>";
> global $password; // doesn't work
> echo "password is: \"$password\"<br>";
> echo "</body></html>";
> ?>
>
>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!
>
>
>

In response to

Responses

Browse pgsql-php by date

  From Date Subject
Next Message Jurgen Defurne 2002-05-29 16:13:38 Re: using CURSOR with PHP
Previous Message Jules Alberts 2002-05-29 14:46:15 variable visibility when using <a href></a>