我有 login.php 包括登录类和登录进行处理。我在 index.php 中包含 login.php
无法理解为什么验证不起作用,这是代码:
登录.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>
我只是将它包含在 index.php
<?php
include_once ('php/ooplogin.php');
?>
我在这里想念什么?