hello people i'm new to oop and i'm trying to build from scratch an oop members system i've made a part of the code but i run into some trouble when i tried to login it doesn't give me any error .. or message.. can someone please help me ?
mysql class:
<?php
class MySQL {
var $totalTime = 0;
function MySQL() {
global $config;
$host = $config['db_host'];
$db_user = $config['db_user'];
$db_pass = $config['db_password'];
$dba = $config ['db_database'];
$startTime = $this->getMicroTime();
mysql_connect($host, $db_user, $db_pass) or die("Could Not Connect To DataBase");
mysql_select_db($dba) or die("Could Not Select DataBase");
$this->totalTime += $this->getMicroTime() - $startTime;
}
// MySQL Query Command
function Query($sql) {
$startTime = $this->getMicroTime();
++$this->queryCounter;
$result = mysql_query($sql);
if (mysql_error()) {
$this->mailError($sql, mysql_error(), mysql_errno());
return $this->error("<br />There was a SQL error and it has been reported. Sorry for the inconvience. <br />");
}
$this->totalTime += $this->getMicroTime() - startTime;
return $result;
}
// MySQL Fetch Arrray Query
function FetchArray($result) {
$rows = mysql_fetch_array($result);
return $rows;
}
// mysql_num_rows
function NumRows($result) {
$count = mysql_num_rows($result);
return $count;
}
}
?>
the next parts of the php are connected togther.
this part it's checking what form has been submited and then goes to onther function:
<?php
class Process {
function Process() {
global $session;
if(isset($_POST['login'])) {
$this->Login();
}
function Login() {
global $session;
$cmd = $session->Login($_POST['user'], $_POST[pass], isset($_POST['remember']));
if($cmd) {
header ("Location:index.php");
}
}
?>
the next part is where i start my session and include it in index.php
<?php
class Session {
function Session() {
$this->time = time();
$this->StartSession();
}
function StartSession() {
global $users;
session_start();
$this->logged_in = $this->CheckLogin();
}
function Login($Luser, $Lpass, $Lremember) {
global $users, $form;
$field = "user"; // Username Name Field.
if(!$Luser || strlen($subuser = trim($Luser)) == 0) {
$error['test'];
}
else {
if(!eregi("^([0-9a-z])*$", $Luser)) {
$error['test'];
}
}
$field = "pass";
if(!$Lpass) {
$error['test'];
}
if($form->num_errors > 0) {
return false;
}
$Luser = stripslashes($Luser);
$result = $users->ConfirmLogin($Luser, md5($Lpass));
if($result == 1) {
$field = "user";
$error['test'];
} else
if($result == 2) {
$field = "pass";
$error['test'];
}
if($form->num_errors > 0) {
return false;
}
$this->username = $_SESSION['username'] = $this->userinfo['username'];
if($Lremember) {
setcookie("cookname", $this->username, time()+COOKIE_EXPIRE, COOKIE_PATH);
}
return true;
}
?>
and this is my last part of php code here i check in database for user.
<?php
require 'mysql.class.php';
$db = &new MySQL();
class Users {
function ConfirmLogin($username, $password) {
global $db;
$select = "SELECT password FROM `sys_members` WHERE login = '$username'";
$result = $db->Query($select);
if(!$result || ($db->NumRows($result) < 1)) {
return 1;
}
$dbarray = $db->FetchArray($result);
$dbarray['password'] = stripslashes($dbarray['password']);
$password = stripslashes($password);
if($password == $dbarray['password']) {
return 0;
} else {
return 2;
}
}
?>
can please someone help me i don't know why it doesn't work