[PHP] Authentication with register_globals OFF

2002-05-11 Thread Mike P

OK, this is an authentication with PHP newbie question...

Env:
WinNT 4.0, SP6a
PHP 4.2.0
Apache 2.0.36
MySQL 4.0.1
Development/sandbox

Trying to get accustomed to PHP 4.2.0 and PHP's preference for
register_globals off, I have register_globals off.

However, when I try to use $PHP_AUTH_USER and $PHP_AUTH_PW, my script fails
(attempting to validate username and password credectials against MySQL...no
error message and my login failure message does not show up, even after
three unsuccessful challenge responses.

When I set register_globals on, I am successful in gaining authorization
(ie, the header('WWW-Auth' is correct, the script works, the MySQL
connection works and the query works).

How, then do I define th $PHP_AUTH_USER and $PHP_AUTH_PW variables up front
with register_globals off?

The docs offer nothing that has led me to a logical answer.

TIA!!

Mike =script copied below

?php

 // Check to see if $PHP_AUTH_USER already contains info

 if(!isset($PHP_AUTH_USER)) {

  // If empty, send header causing dialog box to appear

  header('WWW-Authenticate: Basic realm=Authentication Area');
  header('HTTP/1.0 401 Unauthorized');
  echo You can't get in!;
  exit;

 } elseif(isset($PHP_AUTH_USER)){

  // If non-empty, check the database for matches
  // connect to MySQL

  $db=mysql_pconnect(host, username, password)

   or die(Unable to connect to database.);

  // select database on MySQL server

  mysql_select_db(mydb,$db)
   or die(Unable to select database.);

  // Formulate the query

  $sql = SELECT username, password
FROM auth
WHERE username='$PHP_AUTH_USER' AND
password='$PHP_AUTH_PW';


  // Execute the query and put results in $result

  $result = mysql_query($sql);

  // Get number of rows in $result. 0 if invalid, 1 if valid.

  $num = mysql_numrows($result);

  if($num != 0) {
   echo PYou are authorized!/p;
   exit;

  } else{

  header('WWW-Authenticate: Basic realm=Authentication Area');
  header('HTTP/1.0 401 Unauthorized');
  echo You need to login with correct credentials.;
  exit;

  }

 }

?






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: DOMXML in 4.2.0 problems

2002-05-10 Thread Mike P

I am having similar difficulties with DOMXML in php4.2.0.
phpinfo() indicates all is well with the setup...

If you get some response, please share!

Thanks!

Mike
Thalis A. Kalfigopoulos [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I'm trying to get DOMXML to work with PHP4.2.0. I've compiled
with --with-dom and phpinfo() says it's there:
 DOM/XML enabled
 libxml Version 2.4.18
 HTML Support enabled
 XPath Support enabled
 XPointer Support enabled

 The following program though doesn't seem to work:

 $xmlstring='a valid xml document here';
 $domdoc=xmldoc($xmlstring);
 $root=$doc-document_element(); --- throw error

 I get an error regarding the call to DomDocument-document_element(). Also
I'm forced to use xmldoc() instead of the newer domxml_open_mem() because it
is also not recognized. What am I missing?

 thanks in advance,
 Thalis




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Explain recordset

2001-04-14 Thread Mike P

I'm trying to figure out the way recordsets are handled with php and 
mysql.After I issue a query to the Db with $result = mysql_query ($query) 
is the recordset contained in $result or is this just a pointer.I want a 
persistant recordset on the client computer that can be manipulated without 
going to the server.Is this possable.fetchrow seems to go to the server 
each time or am i wrong?
Thanks
Mike P
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Fetch_row

2001-04-12 Thread Mike P

Can I use Mysql fetch_row to specify which row i want to get? 
Like---$row[5]=mysql_fetch_row($result) ?
Mike P
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Curser

2001-04-12 Thread Mike P

While Im on the subject Is there anything that resembles a recorset 
curser I can use with mysql?
Mike P
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Row colors

2001-04-08 Thread Mike P

I can change the column sof a table with the following code but how do I 
change the row colors instead.With the columns I have "i" to manipulate but 
not with rows.

while ($row = mysql_fetch_row($result))
{{
echo "TR\n";
for ($i =1;$imysql_num_fields($result);$i++)
{$cell_color = "#C0C0C0";
$i % 2  ? 0: $cell_color = "#CC";
echo "td bgcolor=\"$cell_color\"$row[$i]/td";
Thanks 
Mike P
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Mysql question(s)

2001-01-23 Thread Mike P

I created a table with FaceMysql that had one field and I could not add data
to it .Only when I recreated it with 2 fields and a primary key did it
work.Is there any reason for this?Must there always be a primary key in
Mysql?I've never known this to be true of relational Db's.Especially if you
can't implement a foriegn key.Mike P
[EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] FaceMysql again

2001-01-23 Thread Mike P

It seems to only allow me to add data  if I have more than 1 field.Is this a
bug?Phpmyadmin doesnt have this problem.
Mike P
[EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]