The errors are: 

> 
> 1. Could not connect to MySQL: Access denied for user 'ZEBRAHEAD'@'localhost' (using password: YES)
> 
> 
> 	2. Warning: mysql\_connect(): Access denied for user 'ZEBRAHEAD'@'localhost' (using password: YES) in
> 	 C:\wamp\www\TestSite\authentication.php on line 12
> 
> 
> 

DB\_USER is using computer's name. 

**authentication.php**

---

```
<?php

$authorized = FALSE;

if ((isset($_SERVER['PHP_AUTH_USER']) AND isset($_SERVER['PHP_AUTH_PW'])))
{
    define ('DB_USER','ZEBRAHEAD');
    define ('DB_PASSWORD','password');
    define ('DB_HOST','localhost');
    define ('DB_NAME','registration');

    $dbc = mysql_connect (DB_HOST,DB_USER,DB_PASSWORD) OR die ('Could not  connect to MySQL: '.mysql_error());
    mysql_select_db (DB_NAME) OR die ('Could not select the database: '.mysql_error());

    $query ="SELECT first_name FROM users WHERE username='{$_SERVER['PHP_AUTH_USER']}' AND password=PASSWORD('{$_SERVER['PHP_AUTH_PW']}')";
    $result = mysql_query($query);
    $row=mysql_fetch_array ($result);
    if ($row)
    {
        $authorized = TRUE;
    }
}

if(!$authorized) 
{
    header('WWW-Authenticate: Basic realm="My WebSite"');
    header ('HTTP/1.0 401 Unauthorized');
}
?>

```

**index.php**

---

```
<?php

require_once('authentication.php');
?>
<html>
<head></head>
<body>
if ($authorized)
{
    echo "<p>Please enter a valid username and password!</p>";
}
else
{
    echo "<p>You have been authenticated!</p>";
}
?>
</body>
</html>

```