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

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

 



you closed the class before the defining the isLoggedin function
check it out
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("incorrect 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;
		}
	}
}





--- In php-objects@xxxxxxxxxxxxxxx, "la_t3leeq" <la_t3leeq@...> wrote:
>
> 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("incorrect 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->isLoggedin('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 !!
>



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

  Powered by Linux