I have login.php including login class and login for handling. I'm including the login.php in index.php
Cant understand why validation not working, here is the code:
login.php
<?php
include_once('Database.php');
class login extends Database{
protected $_db;
public $_error;
public $_password;
public $_email;
public function __construct(){
$this->_db = new Database('localhost','root','','kupon') or $this->_error = 'Could not connect to database';
}
public function validate($email, $password){
$query = $this->_db->query("SELECT * FROM users WHERE email='$this->_email' AND password ='$this->_password'");
$rows = $this->_db->numrows();
if($rows == 1){
$result = mysql_fetch_assoc($query);
if ($results['email'] == $email && $results['password'] == $password);
return true;
} else{
$this->_error = '<p> User Does not exists</p>';
}
}
}
$login = new login();
if (isset($_POST['email']) && isset($_POST['password'])){
$email = $_POST['email'];
$password = $_POST['password'];
if($login->validate($email, $password))
echo 'your in';
}
?>
<form action="index.php" method="post" class="form">
<p class="email">
<input type="text" name="email" /> :דואר אלקטרוני</br>
</p>
<p class="password">
<input type="password" name="password" /> :סיסמא</br>
</p>
<p class="submit">
<input type="submit" value="היכנס" />
</p>
</form>
And I just include it in index.php
<?php
include_once ('php/ooplogin.php');
?>
What am I missing here?