Here are some examples that you can use in your code to make use of PHP Auth.
require_once 'Auth.class.php';
$auth = new Auth;
if ($auth->loggedIn) {
// the user is logged in
}
$theUser = array(
"username" => $username,
"password" => $password,
"url" => $url,
"ip" => $auth->userIP
);
$numUsers = $auth->numUsers($theUser); // returns number of user with included user info
if ($numUsers == 1){
$auth->login($theUser);
}
$added = $auth->addUser($theUser);
if (is_array($added)){
$problems = array();
foreach ($added as $key => $value){
if ($value["problem"] == "unique")
$theProblem = "<font color=red>« already taken</font>";
if ($value["problem"] == "required")
$theProblem = "<font color=red>« required</font>";
if ($value["problem"] == "not valid")
$theProblem = "<font color=red>« not a valid username</font>";
array_push($problems, $theProblem);
}
} else {
// the user was succesfully added
}
$auth->logout();
|