pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Seader, Cameron <CSeader@idahopower.com>
To: pgsql-php@postgresql.org
Subject: HTTP_AUTH and SQL WHERE Clause
Date: Sat, 27 Sep 2003 14:57:27 -0600
Message-ID: <71B8A8BEC516CF46835CA629156CF21163F5CE@bedford.idacorp.local> (raw)

Hey Folks, 
I am having trouble with some variables the $HTTP_AUTH_USER and $HTTP_AUTH_PW - now im useing PHP 4.3.3 and so i know that you have to use $_SERVER['HTTP_AUTH_USER'] and $_SERVER['HTTP_AUTH_PW'] instead of the old way now. Well i am having trouble with this script i have created to authenticate user name and password and verify against a postgresql database below. 

$auth = false; // Assume user is not authenticated 

if (isset( $_SERVER['PHP_AUTH_USER'] ) && isset($_SERVER['PHP_AUTH_PW'])) { 

// Connect to MySQL 

pg_pconnect("host=172.18.204.64 port=5432 dbname=acquisuite_db user=pgadmin password=pgadmin") or die ( 'Unable to connect to server.' ); 

// Select database on MySQL server 

// mysql_select_db( 'your_db' ) 
// or die ( 'Unable to select database.' ); 

// Formulate the query 

$sql = ("SELECT * FROM tbl_authenticate WHERE username = '$PHP_AUTH_USER' AND password = '$PHP_AUTH_PW'"); 

// Execute the query and put results in $result 

$result = pg_exec( $sql ) 
or die ( 'Unable to execute query.' ); 

// Get number of rows in $result. 

$num = pg_num_rows( $result ); 

if ( $num != 0 ) { 

// A matching row was found - the user is authenticated. 

$auth = true; 

} 

} 

The Problem is on the $sql line when i put in the string to do the Query with the WHERE clause having the $HTTP_AUTH_USER and $HTTP_AUTH_PW. When i change it to '$_SERVER['HTTP_AUTH_USER']' and '$_SERVER['HTTP_AUTH_PW']' it does not work and i get a parse error. 
How can i get around this? 
does anyone have any ideas for me. 
Thanks 

Cameron Seader
CSeader@Idahopower.com



[INFO] -- Access Manager:
This transmission may contain information that is privileged, confidential and/or exempt from disclosure under applicable law.  If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format.  Thank you.   A2





view thread (4+ messages)  latest in thread

Message-ID: <71B8A8BEC516CF46835CA629156CF21163F5CE@bedford.idacorp.local>
Permalink:  ../71B8A8BEC516CF46835CA629156CF21163F5CE@bedford.idacorp.local/
Also on:    postgresql.org/message-id/71B8A8BEC516CF46835CA629156CF21163F5CE@bedford.idacorp.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: CSeader@idahopower.com
  Subject: Re: HTTP_AUTH and SQL WHERE Clause
  In-Reply-To: <71B8A8BEC516CF46835CA629156CF21163F5CE@bedford.idacorp.local>
  References: <71B8A8BEC516CF46835CA629156CF21163F5CE@bedford.idacorp.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