<?
include("config.php");
session_start();
session_unregister(username);
session_unregister(password);
if (($username)&&($submit)&&($password)&&($repeat))
   {
    $users=file($userpath);
    $sum=count($users);
    for($i=0;$i<$sum;$i++)
	{
	$detail=explode("|", trim($users[$i]));
	if($username==$detail[0]){$check=1;;break;}
        }
    if(($check!=1)&&($password==$repeat))
	{
	$fp=fopen($userpath,"a+");
	fwrite($fp,"$username|$password\n");
	fclose($fp);
	echo "注册成功！\n";
	session_start();
        session_register("username");
        session_register("password");
	echo "<script>document.location.href='$path'</script>";
	}
    elseif($password!=$repeat) echo "两次密码输入不一致！请重试。";
          else echo "用户名已存在，请换一个名字申请！";
}
?>
<title>注册页面</title>
<link rel="stylesheet" href="<? echo $csspath; ?>" type="text/css">
<form action="sign.php" method=post>
  您的户名：
<input type=text name=username <?if(isset($username))echo"value=$username";?>><br>
  您的密码：
<input type=password name=password><br>
  重复密码：
<input type=password name=repeat>
  <br>
<input type=submit name=submit value="马上注册"><input type=reset name=reset value="清除输入">
</form>
