AUTH: display custom login error message

From: Date: Tue, 06 Sep 2005 15:41:13 +0000
Subject: AUTH: display custom login error message
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-20819@lists.php.net to get a copy of this message
I found the following page that most closely resembles what I am trying to do: http://www.codecomments.com/archive218-2004-6-219863.html And that is to simply let the user know why their login is not working - idle, expired, wrong login. I tried the code suggestion in that link and can not get it to work. Below is what I've tried. Any ideas? <?php require_once "Auth.php"; $opts = array('table' => 'tablename', 'col1' => 'user__ID','dsn' => 'mysql://username:passwprd@localhost/dbname'); $a = new Auth("DB", $opts, "loginFunction"); $a->start(); $errorMessages = array( AUTH_IDLED => 'idle for too long, log in again', AUTH_EXPIRED => 'session expired, log in again', AUTH_WRONG_LOGIN => 'wrong username/password combination, try again' ); function loginFunction() { echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <script language="JavaScript" type="text/JavaScript"> <!-- function fieldFocus(frm, fld) { document.forms[frm].elements[fld].focus() } //--> </script> </head> <body onLoad="fieldFocus(0,0)"> echo "<form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "\">"; $errcode = $a->getStatus(); if ($errcode < 0) { echo $errorMessages[ (string) $errcode ]; } echo "<label>User Name: </label><input type=\"text\" name=\"username\"><BR>"; echo "<label>Password: </label><input type=\"password\" name=\"password\"><BR><BR>"; echo "<input type=\"submit\" value=\"Submit\">"; echo "</form>"; </body> </html>'; } if ($a->checkAuth()) { require_once("DB.php"); require(connection.php'); header("Location: index.php"); } ?> ______________________________________________________ Click here to donate to the Hurricane Katrina relief effort. http://store.yahoo.com/redcross-donate3/

« previous php.pear.general (#20819) next »