<?php session_start(); ?>

<?php
require("connect.php");
?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文件</title>
</head>

<?php

if ($_POST['action'] == "dologin" ) {
	$account=$_POST['account'];
	$password=$_POST['password'];

	$sql="select * from bkstage_user where account='$account' and password='$password'";
//	echo $sql;
	$result=mysql_query($sql);

	$num_rows=mysql_num_rows($result);
	if ($num_rows == 0) {
	   $_SESSION['login_state']="no";
	} else {
	   $_SESSION['login_state']="yes";
	   echo "<script language='JavaScript'>window.location.href='index.php';</script>";
	}  
}

?>


<body>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<table width="402" height="167" border="1" align="center">
  <tr>
    <td width="385" height="161" align="center" bgcolor="#DFDFDF">
    
    <form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
        <input type="hidden" name="action" value="dologin">
      <p>
        <label for="account"></label>
        帳號：
        <input type="text" name="account" id="account" />
      </p>
      <p>
        <label for="password">密碼：</label>
        <input type="password" name="password" id="password" />
      </p>
      <p>
        <input type="submit" name="confirm" id="confirm" value="送出" />
        　
        <input type="reset" name="cancel" id="cancel" value="重設" />
      </p>
    </form>
    
    </td>
  </tr>

<?php
	if ($_SESSION['login_state']=='no') echo "<tr><td align=center><font color=red>帳號或密碼有誤！　請再次輸入！</font></td></tr>";
?>

</table>

</body>
</html>