Auth_HTTP Example 2

Auth_HTTP Example 2 – Example: A password protected page with multiple rows fetch and md5 password


// example of Auth_HTTP implementation with encrypted password and multiple columns fetch


// setting the database connection options
$AuthOptions = array(
'table'=>"testable",                            // your table name 
'usernamecol'=>"username",            // the table username column
'passwordcol'=>"password",            // the table password column
'cryptType'=>"md5",                // password encryption type in your db
'db_fields'=>"*",                // enabling fetch for other db columns

$a = new Auth_HTTP("DB"$AuthOptions);

$a->setRealm('yourrealm');            // realm name
$a->setCancelText('<h2>Error 401</h2>');        // error message if authentication fails
$a->start();                    // starting the authentication process

if($a->getAuth())                // checking for autenticated user 
"Hello $a->username welcome to my secret page <BR>";
"Your details on file are: <BR>";
$a->getAuthData('userid');        // retriving other details from the database row
echo $a->getAuthData('telephone');      // in this example the user id, telephone number
echo $a->getAuthData('email');        // and email address
Example: A simple password protected page (Previous) check for an authenticated user (Next)
Last updated: Fri, 27 Nov 2015 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

Note by: doconnor
Nope: not a typo :)
Note by:

type-oh? dsn->DNS?