Foros del Web » Programando para Internet » PHP »

PHP OO error extraño en un my class

Estas en el tema de error extraño en un my class en el foro de PHP en Foros del Web. Notice: Undefined variable: value in C:class.login.php on line 99 Warning: Creating default object from empty value in C:class.login.php on line 99 Fatal error: Cannot access ...
  #1 (permalink)  
Antiguo 27/10/2012, 09:16
 
Fecha de Ingreso: septiembre-2012
Mensajes: 14
Antigüedad: 11 años, 7 meses
Puntos: 0
Pregunta error extraño en un my class

Notice: Undefined variable: value in C:class.login.php on line 99

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">&nbsp;</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'])? 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'])? 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']))? 0;    
    }
    public function 
showErrors()
    {
        echo 
"<h3>errores</h3>";
        foreach(
$this->_errors as $key->$value)
        {
            echo 
$value."<br />";
        }
    }
}
?>
  #2 (permalink)  
Antiguo 27/10/2012, 11:15
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: error extraño en un my class

Imagino que la siguiente linea es la del error.
Código PHP:
foreach($this->_errors as $key->$value
¿Sabes bien lo que está sucediendo ahí o no?
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.

Etiquetas: php+base
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:11.