PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Cannt get Auth working - class error

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Authentication
View previous topic :: View next topic  
Author Message
sacadia



Joined: 25 Aug 2008
Posts: 2

PostPosted: Mon Aug 25, 2008 2:27 pm    Post subject: Cannt get Auth working - class error Reply with quote

I am getting the following error:

Fatal error: Class 'Auth' not found in /hsphere/local/home/sacadia/stampederecruitment.com/admin/xxsr.php on line 33

Can anyone help me!

Code:

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set("include_path", "/hsphere/local/home/sacadia/stampederecruitment.com/pear/");
require_once '../pear/PEAR/PEAR.php';
PEAR::setErrorHandling(PEAR_ERROR_DIE);
require_once "../pear/PEAR/Auth/Auth.php";

function loginFunction()
{
     /*
      * Change the HTML output so that it fits to your
      * application.
      */
     echo "<form method=\"post\" action=\"xxsr.php?login=1\">";
     echo "<input type=\"text\" name=\"username\">";
     echo "<input type=\"password\" name=\"password\">";
     echo "<input type=\"submit\">";
     echo "</form>";
}

if (isset($_GET['login']) && $_GET['login'] == 1) {
     $optional = true;
} else {
     $optional = false;
}

$options = array(
  'dsn' => 'mysql://user:password@host/database',
  );

$a = new Auth("MDB2", $options, "loginFunction");

$a->start();

echo "Everybody can see this text!<br />";

if (!isset($_GET['login'])) {
     echo "<a href=\"xxsr.php?login=1\">Click here to log in</a>\n";
}

if ($a->getAuth()) {
    echo "YOU ARE LOGGED IN!";
  } else {
   echo 'I am not logged in';
   echo '<br>'.$_GET['login'];
}
?>


Thanks
Stephen
Tuckerplace aatt hotmail doot com
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Mon Aug 25, 2008 5:00 pm    Post subject: Reply with quote

Did you search the archives about error handling? I know the first lines of your code very good. Wink

Anyway, I see two problems:
- PEAR.php seems to be in a directory named "PEAR" which is inside the directory that is specified in the include_path => you could append "PEAR/" to the include_path
- the require_once calls shouldn't contain that much path information => you should shorten them to just 'PEAR.php' and 'Auth/Auth.php' (this requires a correct include_path setting, of course)
Back to top
View user's profile Send private message
sacadia



Joined: 25 Aug 2008
Posts: 2

PostPosted: Mon Aug 25, 2008 7:03 pm    Post subject: Seems so different to the way I have been coding Reply with quote

But it works.

Thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Authentication All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software