pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Viorel Dragomir <bc@vio.ro>
To: Yasmine Kedoo <yazkedoo@hotmail.com>
To: pgsql-php@postgresql.org
Subject: Re: PHP Username & Password Detection From PSQL Database
Date: Wed, 7 Apr 2004 12:18:08 +0300
Message-ID: <008c01c41c81$3e6609d0$6500a8c0@wylog.local> (raw)
References: <BAY14-F46HSspJ1f12o0002c9b0@hotmail.com>

:)
For start you need ) here:
if( trim($PHP_AUTH_USER) == trim($username) && (trim($PHP_AUTH_PW)) )
  ----- Original Message ----- 
  From: Yasmine Kedoo 
  To: pgsql-php@postgresql.org 
  Sent: Wednesday, April 07, 2004 11:59 AM
  Subject: [PHP] PHP Username & Password Detection From PSQL Database


  Hi.

  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:

  if(!isset($PHP_AUTH_USER))
  {
  Header("WWW-Authenticate: Basic realm=\"Authentication\"");
  Header( "HTTP/1.0 401 Unauthorized");

  echo "No Login\n";
  exit;
  }
  else
  {
  echo "User: $PHP_AUTH_USER<BR>";
  echo "Password: $PHP_AUTH_PW<BR>";
  }
  <?PHP
  $database = pg_connect("host=pgdbs.inf.brad.ac.uk dbname=yamkedoo 
  user=yamkedoo password=yamkedoo");

  if(!$database)
       {
          print "Connection to database failed.";
       }

  else
                         {
                         $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;
  }

        if($auth==0)
       {
       print "Access Denied<BR>\n";
       exit;
       }


  ?>

  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: 
  http://www.cyber.brad.ac.uk/~yamkedoo/Tests/referrals2.php to see what is 
  happening.
  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! 
  http://www.msn.co.uk/messenger


  ---------------------------(end of broadcast)---------------------------
  TIP 9: the planner will ignore your desire to choose an index scan if your
        joining column's datatypes do not match

view thread (7+ messages)  latest in thread

Message-ID: <008c01c41c81$3e6609d0$6500a8c0@wylog.local>
Permalink:  ../008c01c41c81$3e6609d0$6500a8c0@wylog.local/
Also on:    postgresql.org/message-id/008c01c41c81$3e6609d0$6500a8c0@wylog.local

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: bc@vio.ro, yazkedoo@hotmail.com
  Subject: Re: PHP Username & Password Detection From PSQL Database
  In-Reply-To: <008c01c41c81$3e6609d0$6500a8c0@wylog.local>
  References: <BAY14-F46HSspJ1f12o0002c9b0@hotmail.com> <008c01c41c81$3e6609d0$6500a8c0@wylog.local>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox