Re: call to undefined method error ( but i defined it !!)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Your object is $obj and not $this . We call $this inside a class .

$obj = new login;



if(!$obj->isLoggedi n('admin' )){

	if($obj->sentData( )){

        $this->setData( $_POST['username '],$_POST[ 'password' ]);

        $this->doLogin( );

So please change the lines . I am seeing some spaces .
( Eg : $obj->isLoggedi n('admin' ) ) , don't know whether there is any in the file. So if you still have trouble attach the file , than copy and paste ..

Hari K T

http://harikt.com/


--- On Wed, 17/6/09, la_t3leeq <la_t3leeq@xxxxxxxxx> wrote:

From: la_t3leeq <la_t3leeq@xxxxxxxxx>
Subject:  call to undefined method error ( but i defined it !!)
To: php-objects@xxxxxxxxxxxxxxx
Date: Wednesday, 17 June, 2009, 5:57 AM











    
            
            


      
      hi

this is my class for login



class login{

	public $currentUser;

	private $_uname , $_password;

	function setData($uname, $pass){

		require_once' safeworld. php';

		$obj= new safeworld;

		$this->_uname = $obj->safeString( $uname);

		$this->_password = $obj->safeString( $pass);

	}

	function doLogin(){

		$query_string = "SELECT id FROM users WHERE username = '".$this->_uname. "' and password = '".$this->_password ."'";

		$q = mysql_query( $query_string) ;

		if(mysql_num_ rows($q)< 1){

			throw new Exception("incorrec t data");

		}else{

			$this->setSession( 'admin');

		}

	}

	protected function setSession($ meen){

		$_SESSION['is_ logged']= true;

		$_SESSION['meen' ]= $meen;

	}

}

 function isLoggedin($ meen){



	//if(isset($ _SESSION[ 'is_logged' ])){

		echo "ssssssssssssssss" ;

       // $this->currentUser = $meen;

		//return true;

	//}else{

		//return false;

	//}

	}

function sentData(){

	if(isset($_POST[ 'username' ]) and isset($_POST[ 'password' ])){

		return true;

		

	}else{

		return false;

		

	}

}



and this is the implementation

<?

//here

//are

//some

//comments

//only for the line number

require_once "classes/login. php";

$obj = new login;



if(!$obj->isLoggedi n('admin' )){

	if($obj->sentData( )){

        $this->setData( $_POST['username '],$_POST[ 'password' ]);

        $this->doLogin( );

	}else{

        require_once( "../templates/ loginForm. php");

	}

}else{

	header("Location: admin.php" );

}

?>

and this is the result



Fatal error: Call to undefined method login::isLoggedin( ) in C:\xampp\htdocs\ 5iblog\login. php on line 10



as you can see the method is defined although the error message !!




 

      

    
    
	
	 
	
	








	


	
	


      Own a website.Get an unlimited package.Pay next to nothing.*Go to http://in.business.yahoo.com/

[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux