PHP Authentication Library
This library can be "included" into any PHP application to restrict access to a give page or function.
Unlike .htaccess, which protects an entire directory, this library gives the programmer more fine-tuned control over access. By simply calling the function "authlogin", you can restrict access to an application, or within the application, require different userids and passwords for specific parts of the application.
Setup and Usage
- Download the Library and save it as "authenticate.inc.php"
- In your PHP application, "include" it, like this:
<?php include_once("/path/to/authenticate.inc.php"; ?>
- Then, anywhere in your program, you can make calls to the library, as follows:
Login requiring the username/password below
authlogin();
Login with a custom prompt
$prompt = "Login correctly or leave";
authlogin( '','', $prompt );
Login requiring a passed in username/password:
authlogin( $username, $password );
Login requiring a passed in username/password AND custom prompt
$prompt = "Login correctly or leave";
authlogin( $username, $password, $prompt );
The login function will allow 3 tries, and then generate an error page.
On a successful login, control is returned to your program.
That's it. Note that if you do NOT send in a username/password with the function, the
library will use it's default .... you can change that by editing the library file itself,
right below the copyright notices.