Location: PHPKode > scripts > Some Chess > some-chess/login.php
<?php
//		Some Chess, a PHP multi-player chess server.
//		Copyright (C) 2006 Jon Link
function login($userName,$password,$loginStr){
	$userName	= validate($userName);
	$password	= validate($password);
	if(!$userName || !$password){ 	//--are both fields filled in
		return'<div class="badLog">'.$loginStr[3].'</div>';
	}else{
		$userPassword	= md5($password); 
		$queryPlayers	= 'SELECT id,name,power,pic FROM players WHERE name="'.$userName.'" AND pword="'.$userPassword.'"';
		$resultPlayers	= mysql_query($queryPlayers) or die(errorDBStr.'players database');
		$numPlayers		= mysql_numrows($resultPlayers);
		if($numUsers > 1){			//--if account name isn't unique
			return'<div class="badLog">'.$loginStr[4].'</div>';
		}elseif($numPlayers == 0){ 	//--if login is bad
			return'<div class="badLog">'.$loginStr[5].'</div>';
		}elseif($numPlayers == 1){ 	//--if login is good
			$id 		= mysql_result($resultPlayers,0,'id');
			$name 		= mysql_result($resultPlayers,0,'name');
			$power 		= mysql_result($resultPlayers,0,'power');
			$pic 		= mysql_result($resultPlayers,0,'pic');
			if(!$pic)$pic	= 'default.png';
			session_register('on'); 
			session_start();
			$_SESSION['on'] 	= true;	
			$_SESSION['id'] 	= $id;	
			$_SESSION['name'] 	= $name;
			$_SESSION['power'] 	= $power;	
			$_SESSION['pic'] 	= $pic;	
			return $_SESSION['on'];
		}
	}	
}
?>
Return current item: Some Chess