Nieuw lid |
|
Ik heb volgende login classe geschreven:
<?php
//LOGIN CLASS
Class Login{
private $username;
private $password;
public function __construct($user,$pass){
$this->username=$user;
$this->password=$pass;
}
public function Check($table,$field_username,$field_password){
//table= the table where all valid admin user logins are saved
//$field_username= The field in the database where the username is saved
//$field_password= the field in the database where the user password with md5 encryption is saved
$qry="SELECT COUNT(*) as number FROM ".$table." WHERE ".$field_username."='".$username."'AND ".$field_password."='".$password."'";
echo($qry);
//echo($username);
//echo($password);
$res=mysql_query($qry) or die(mysql_error());
$number=mysql_result($res,0,0);
echo($number);
}
}
?>
<?php //LOGIN CLASS Class Login{ private $username; private $password; public function __construct($user,$pass){ $this->username=$user; $this->password=$pass; } public function Check($table,$field_username,$field_password){ //table= the table where all valid admin user logins are saved //$field_username= The field in the database where the username is saved //$field_password= the field in the database where the user password with md5 encryption is saved $qry="SELECT COUNT(*) as number FROM ".$table." WHERE ".$field_username."='".$username."'AND ".$field_password."='".$password."'"; //echo($username); //echo($password); } } ?>
Nu heb ik dat gebruikt in combinatie met volgende index file:
<?php if(isset($_POST['cmdLogin'])){
$login=new Login($_POST['txtGebruikersnaam'],$_POST['txtWachtwoord']);
$mysql_connect=new Mysql_connect("localhost","root","mysql");
$mysql_connect->mysql_db_connect("mailinglist");
$login->Check("validlogins","username","password");
$mysql_connect->mysql_disconnect();
}
?>
<?php if(isset($_POST['cmdLogin'])){ $login=new Login($_POST['txtGebruikersnaam'],$_POST['txtWachtwoord']); $mysql_connect->mysql_db_connect("mailinglist"); $login->Check("validlogins","username","password"); $mysql_connect->mysql_disconnect(); } ?>
Hij voert de constructor uit (ik heb een echo gedaan in de constructor) wat hij doet, wanneer hij de functie om de login te checken uitvoer komt hij daar ook , maar hij vult de variabelen niet meer in, ze zijn blijkbaar gewoon leeg.
Wat doe ik fout?
|