Skip site navigation (1) Skip section navigation (2)

PHP Username & Password Detection From PSQL Database

From: "Yasmine Kedoo" <yazkedoo(at)hotmail(dot)com>
To: pgsql-php(at)postgresql(dot)org
Subject: PHP Username & Password Detection From PSQL Database
Date: 2004-04-07 08:59:50
Message-ID: (view raw or whole thread)
Lists: pgsql-php

I am just beginning to work with PHP & PSQL so forgive me if i make simple 
mistakes. :-)

I created my PSQL database via telnet on my university's database server. I 
have no problems retrieving and displaying certain data using PHP, but i am 
unable to recognise a username and password entered via a predefined 
authentication variable, $PHP_AUTH_USER.

The script must recognise the username: 'yamkedoo', and password: 'yasmine'. 
In the database, the username & password columns are spelt exactly as: 
'username' & 'password'. The database name is 'yamkedoo', and the table name 
is 'PatPerInfo', as can be seen from the following code:

			Header("WWW-Authenticate: Basic realm=\"Authentication\"");
			Header( "HTTP/1.0 401 Unauthorized");

			echo "No Login\n";
			echo "User: $PHP_AUTH_USER<BR>";
			echo "Password: $PHP_AUTH_PW<BR>";
	$database = pg_connect(" dbname=yamkedoo 
user=yamkedoo password=yamkedoo");

        		print "Connection to database failed.";

        	               $selectquery = "SELECT * FROM PatPerInfo";
          	               $result = pg_exec($database, $selectquery);

		$maxrows = pg_numrows($result);
           		$maxfields = pg_numfields($result);

          		for ($rw = 0; $rw < $maxrows; $rw++)
   				$username = pg_Result($result,$rw,0);
				$password = pg_Result($result,$rw,1);

				if( trim($PHP_AUTH_USER) == trim($username) && (trim($PHP_AUTH_PW))
		  		 	$auth = 1;

		     echo $auth;

     			print "Access Denied<BR>\n";


After the username and password, i get the following error: Parse error: 
parse error in /home/webpages/yamkedoo/Tests/referrals2.php on line 44.

Please view te following link: to see what is 
Only once has the authentication window appeared, and has not done so since. 
It only gives the error as seen at the link.

Can anyone help?

Thank You :-)

It's fast, it's easy and it's free. Get MSN Messenger today!


pgsql-php by date

Next:From: Viorel DragomirDate: 2004-04-07 09:18:08
Subject: Re: PHP Username & Password Detection From PSQL Database
Previous:From: Muhyiddin A.M HayatDate: 2004-04-06 18:31:12
Subject: Re: Connection problems

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group