Oscar Del ben wrote:
> What should !isset do? It's not obvious that we know php
> 
Oscar I need Basic Authenticate! I use Ruby CGI!


<?php

if(!isset($PHP_AUTH_USER))
// user unknown
  {
  Header("WWW-Authenticate: Basic realm=\"Admin Center\"");
  Header("HTTP/1.0 401 Unauthorized");
  exit();
  }
else
// User - Ok, unknown password
  {
  // password insert
  $password = "$PHP_AUTH_PW";
  // ާ ҧѧ٧ էݧ ݧ֧ߧڧ ֧ѧݧߧԧ ѧݧ
  $link = mysql_connect($dbhost, $dbuser, $dbpasswd);
  mysql_select_db($dbname);
  $result=mysql_query("SELECT password FROM auth WHERE 
name=\"$PHP_AUTH_USER\"");
  $row=mysql_fetch_array($result);
  // ӧ֧ܧ
  if ($row==NULL)  // in DB user unknown
    {
    Header("WWW-Authenticate: Basic realm=\"Admin Center\"");
    Header("HTTP/1.0 401 Unauthorized");
    exit();
    }
  else      // In DB User Ok, check password
{
    $real_password="$row[password]";
    if ($real_password!=$password)
      {
      Header("WWW-Authenticate: Basic realm=\"Admin Center\"");
      Header("HTTP/1.0 401 Unauthorized");
      exit();
      }
    }
  }

?>
-- 
Posted via http://www.ruby-forum.com/.