Versuche grade ein LoginScript via OOP (halbswegs) zu realisieren. Dazu sei erwähnt, dass das ziemlich neu für mich ist, also bitte nicht schlagen
bekkome diesen Fehler:
login.php:
login.class.php:
bekkome diesen Fehler:
und weiss einfach nicht wieso... Hier mein Script:Fatal error: Call to a member function query_first() on a non-object in /www/htdocs/w0070625/_acp/lib/modules/login.class.php on line 41
login.php:
PHP:
$area = "login";
$fileName = "login.class.php";
// initiate acp
require_once(LIB_DIR."ACP.class.php");
// create classes
$db = &new db($sqlhost, $sqluser, $sqlpassword, $sqldb, $phpversion);
$login = new login();
login.class.php:
PHP:
/**
* this class handles the login
*/
class login {
protected $redirectionTime = 3;
protected $redirectionLocation = "shoutbox.php";
/**
* constrcutor: if $username or $password exists:
* redirect to shoutbox
*/
public function __construct() {
$db = &new db($sqlhost, $sqluser, $sqlpassword, $sqldb, $phpversion);
$POST_username = strip_tags(trim($_POST['username']));
$POST_password = md5(strip_tags(trim($_POST['password'])));
$COOKIE_username = strip_tags(trim($_COOKIE['fckr_password']));
$COOKIE_password = md5(strip_tags(trim($_COOKIE['fckr_password'])));
$this->loadTemplates("login.tpl");
if ((isset($COOKIE_username) && $COOKIE_username != "") && (isset($COOKIE_password) && $COOKIE_password != "")) {
echo "COOKIE JA";
if ($this->checkUsernameAndPassword($this->getUserIdFromUsername($COOKIE_username), $COOKIE_password) == 1) {
msgRedirect("Deine Anmeldung war erfolgreich.",$redirectionTime,$redirectionLocation);
echo "COOKIE OK";
} else {
echo "COOKIE NICHT OK"."<br />";
}
} else {
echo $POST_username."<br />";
echo $POST_password."<br />";
if ($this->checkUsernameAndPassword($this->getUserIdFromUsername($POST_username), $POST_password) == 1) {
echo "POST OK";
} else {
echo "POST NICHT OK"."<br />";
}
}
}
public function getUserIdFromUsername($username) {
$userData = $db->query_first("SELECT `userid` FROM `bb".N."_users` WHERE `username` LIKE ".$username."");
$this->userid = $userData['userid'];
echo "userid: ".$_POST['username'];
}
public function checkUsernameAndPassword($userid, $password) {
$userData = $db->query_first("SELECT `username`, `password` FROM `bb".N."_users` WHERE `userid` = ".$userid."");
if ($this->username == $userData['username'] && $this->password == $userData['password']) {
echo "ERFOLGREICH";
return 1;
}
else echo "NICHT ERFOLGREICH";
}
public function loadTemplates($tpl1, $tpl2 = "", $tpl3 = "", $tpl4 = "", $tpl5 = "", $tpl6 = "") {
$tpl = &new tpl(TPL_DIR);
$tpl->newFile($tpl1);
$tpl->addPlHo("PHP_SELF",$_SERVER['PHP_SELF']);
$tpl->addPlHo("POST_username",$_POST['username']);
$tpl->addPlHo("POST_password",$_POST['password']);
$tpl->parseTemplate();
}
}