Location: PHPKode > scripts > Some Chess > some-chess/register.php
<?php 
//		Some Chess, a PHP multi-player chess server.
//		Copyright (C) 2006 Jon Link
session_start();
include_once('config.php');
include_once('languages/'.$lang.'_main.php');
include_once('constants.php');
include_once('standard.php');
$name	= validate($_POST['username']);
$pass	= validate($_POST['password']);
if($verifyReg){
	$code 	= validate($_POST['code']);
	$theCode= $_SESSION['theCode'];
}
if(!$verifyReg || $code === $theCode){
	echo joinChess($name,$pass,$startPower,$regStr);
}elseif($verifyReg || $code !== $theCode){
	$error	= '<div class="error">'.$regStr[5].'</div>';
}else{
	$error	= '<div class="error">'.$regStr[6].'</div>';
}

include_once('index.php');

function joinChess($name,$pass,$startPower,$regStr){
	$queryPlayers		= 'SELECT name FROM players';
	$resultPlayers		= mysql_query($queryPlayers) or die('<div class="error">'.errorDBStr.'players</div>');	
	$numPlayers			= mysql_num_rows($resultPlayers);
	$now				= date(Ymd);
	for($i=0;$i<$numPlayers;++$i) $names[] = mysql_result($resultPlayers,$i,'name');
	if(!$name || !$pass){
		return '<div class="badLog">'.$regStr[2].'</div>';
	}elseif(array_search($name,$names) !== false){
		return '<div class="badLog">'.$regStr[3].'</div>';
	}else{
		$password	= md5($pass);
		$queryJoin 	= 'INSERT INTO players (name,pword,power,invitedBy,addDate) VALUES ("'.$name.'","'.$password.'","'.$startPower.'","X","'.$now.'")';
		mysql_query($queryJoin)or die('<div class=error>'.errorDBStr.'player</div>');
		return '<div class="message"  style="top:420px;">'.$regStr[4].'</div>';
	}
}
?>
Return current item: Some Chess