Manuel,
Do you have a command line access to the server?

http://httpd.apache.org/docs/programs/htpasswd.html
     htpasswd -b /var/www/html/db/tools/htpasswd.users jdaxell ****** (batch mode)
     htpasswd -c /var/www/html/db/tools/htpasswd.users jdaxell (creation mode)
     htpasswd /var/www/html/db/tools/htpasswd.users jdaxell (add mode)

Here is another way someone sent me - without having to use an .htaccess nor a passwd 
file.

------snip------
NOT needed in fact. Just authenticate and headers.
Working code below. hash it up and try it:

<?php
## add this to any file
include "authenticate.php";
?>

file://authenticate.php :
<?php
 function authenticate() {
   header( "WWW-Authenticate: Basic realm=\"Who are you?\"");
   header( "HTTP/1.0 401 Unauthorized");
   echo "You must enter a valid login ID and password to access this
resource\n";
   exit;
 }

 if(!isset($PHP_AUTH_USER))
  {
  authenticate();
  }elseif(($PHP_AUTH_USER != "user1") || ($PHP_AUTH_PW != "password"))
  {
//  echo $PHP_AUTH_USER." Not allowed!<br>";
//  echo $PHP_AUTH_PW." Not allowed!<br>";
  authenticate();
 }else{
//  echo "</p>Welcome:  $PHP_AUTH_USER<br>";
//  echo "</p>Welcome:  $PHP_AUTH_USER<br>";
//  echo "</p>Password: $PHP_AUTH_PW<br>";
 }
?>

Manuel Lemos wrote:

> Hello,
>
> On 02/24/2004 06:50 PM, Will wrote:
> > I tried to search PHP net for this but found nothing.
> > I am doing an install script and I want to write a htaccess file to the
> > server so people can login in to there admin section.
> >
> > What is the proper way to do this and the easiest way.  I know how to
> > write a file to the server, but how do you do the password thing??
>
> There are many solutions for that. You may want to try this:
>
> Class: htaccess
> http://www.phpclasses.org/htaccess
>
> --
>
> Regards,
> Manuel Lemos


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

Reply via email to