<?
	require_once('link.php');
	mysql_select_db($database,$connect);
	
	if($character == "admin")
	{
		$query = "SELECT * FROM `Member` WHERE `mId` = '$mId' AND `password` = '$pass'";
		$result = mysql_query($query,$connect);
		$record = mysql_fetch_array($result);
	
		if ($record[level]!=2)
		{
			echo "<script language = 'JavaScript'>"; 
			echo "alert('非管理者,請以會員身份登入');"; 
			echo "location.href='login.htm';";
			echo "</script>"; 
		}
		else
		{session_start();
			// 登記 Session 變數名稱
			session_register('mId');
			// 寫入 Session 變數值
			$_SESSION['mId'] = $mId;
			echo "<script language = 'JavaScript'>"; 
			echo "alert('登入成功');"; 
			echo "location.href='admin_link.htm';";  
			echo "</script>"; 
		}
	}
	else
	{
		$query = "SELECT * FROM `Member` WHERE `mId` = '$mId' AND `password` = '$pass'";
		$result = mysql_query($query,$connect);
		$record = mysql_fetch_array($result);
	
		if ($record[mId]!=$mId||$record[password]!=$pass)
		{
			echo "<script language = 'JavaScript'>"; 
			echo "alert('請確認帳號密碼 <無帳號密碼者,請加入會員>');"; 
			echo "location.href='login.htm';";
			echo "</script>"; 
		}
		else
		{session_start();
			// 登記 Session 變數名稱
			session_register('mId');
			// 寫入 Session 變數值
			$_SESSION['mId'] = $mId;
			echo "<script language = 'JavaScript'>"; 
			echo "alert('登入成功');"; 
			echo "location.href='main.htm';";     //加入網站首頁
			echo "</script>"; 
		}
	}
?>