Warning: Creating default object from empty value in C:class.login.php on line 99
Fatal error: Cannot access empty property in C:class.login.php on line 99
ME DA ESOS ERRORES LA VERDAD NO SE POR QUE ES UN FORM SENCILLO LA VERDAD NO SE BIEN POR QUE ES EL ERROR, EN MI SHOW DE ERROR ME DA ESE 3 ERRORES SON 2 ARCHIVOS PHP
login.php
class.login.php
les dejo los 2 no que sera el error
Código PHP:
<fieldset id="login">
<h4>Loguear Solo Miembros</h4>
<form method="post" action="<?=$_SERVER['PHP_SELF']; ?>" >
<p class="clearfix"><label for="username">Usuario:</label>
<input name="username" id="username" type="text" value="" /></p>
<p class="clearfix"><label for="password">Password:</label>
<input name="password" id="password" type="password" value="" /></p>
<input name="token" type="hidden" value="<? $token;?>"/>
<p class="clearfix check"><input type="checkbox" id="remember" name="remember" />
<label for="remember" id="remlabel">Recordarme</label>
<input name="logguear" id="submit" type="submit" value="" /></p>
<?php
if(isset($_POST['logguear']))
{
include('ctrl/class.login.php');
$login=new login();
if($login->isloggedin())
{
header('location: op_administrador.php');
}
else
{
$login->showErrors();
}
}
//$_SERVER['PHP_SELF'];
$token=$_SESSION['token']=md5(uniqid(mt_rand(),true));
?>
</form>
<p class="member"> </p>
</fieldset>
Código PHP:
<?php
class login
{
private $_id;
private $_password;
private $_username;
private $_passmd5;
private $_errors;
private $_acces;
private $_login;
private $_token;
public function __construct()
{
$this->_errors=array();
$this->_login=isset($_POST['logguear'])? 1 : 0;
$this->_acces=0;
$this->_token=$_POST['token'];
$this->_id=0;
$this->_username=($this->_login)? $this-> filter($_POST['username']) : $_SESSION['username'];
$this->_password=($this->_login)? $this-> filter($_POST['password']) : '';
$this->_passmd5=($this->_login)? md5($this->_password) : $_SESSION['password'];
}
public function isloggedin()
{
($this->_login) ? $this->verifypost() : $this->verifysession();
return $this->_acces;
}
public function filter($var)
{
return preg_replace('/[^a-zA-Z0-9]/','',$var);
}
public function verifypost()
{
try
{
if(!$this->isTokenValid())
throw new Exception ('Envío del formulario no válido');
if(!$this->isDataValid())
throw new Exception ('Datos del formulario no válidos');
if(!$this->verifyDataBase())
throw new Exception ('usuario/contraseña no validos');
$this->_acces=1;
$this->registerSession();
}
catch (Exception $e)
{
$this->_errors[]=$e->getMessage();
}
}
public function verifysession()
{
if($this->sessionExist() && $this->verifyDataBase())
{
$this->_acces=1;
}
}
public function verifyDataBase()
{
if($this->_username=='admin'&&$this->_passmd5=='21232f297a57a5a743894a0e4a801fc3')
{
return true;
}
else
{
return false;
}
}
public function isDataValid()
{
return (preg_match('/^[a-zA-Z0-9](5,12)$/',$this->_username)&&preg_match('/^[a-zA-Z0-9](5,12)$/',$this->_password))? 1:0;
}
public function isTokenValid()
{
return (!isset($_SESSION['token'])||$this->_token != $_SESSION['token'])? 0 : 1;
}
public function registerSession()
{
$_SESSION['ID']=$this->_id;
$_SESSION['username']=$this->_username;
$_SESSION['password']=$this->_passmd5;
}
public function sessionExist()
{
return (isset($_SESSION['username'])&&isset($_SESSION['password']))? 1 : 0;
}
public function showErrors()
{
echo "<h3>errores</h3>";
foreach($this->_errors as $key->$value)
{
echo $value."<br />";
}
}
}
?>