登入判斷程式碼問題

edited 十月 2013 in PHP新手區
<?php
include("lib/connect.php");
mysql_select_db("elearning",$link);
session_start();
if (isset($_POST['account']) && isset($_POST['pass']))
{
	if($_POST["select"]=='compiler')
	{
		$sql="SELECT * FROM compiler where account='$account' and pass='$pass' and open_power='1'";
		$test=mysql_query($sql);
		$chk1=mysql_fetch_row($test);
		if($chk1[0] == $account && $chk1[1] == $pass &&  $chk1[0] !='' && $chk1[1] !='' )
		{
			if($in !='') 
			{
				$_SESSION['valid_account'] = $account;
				$_SESSION['valid_compiler'] = $_POST["select"];
			}

?>
	<script>
		parent.mainFrame.location.href="members_only.php";
		location.href="left1.php";
    </script>
<?
		}
		if($account =='' || $pass =='')
		{
			echo "請輸入帳號密碼,系統自動返回";
			header("refresh:1 ; url=../left0.php");
		}
		else
		{
			echo "帳號密碼有誤,系統自動返回";
			header("refresh:1 ; url=../left0.php");
		}
	}

elseif($_POST["select"]=="admin")
{
	$sql="SELECT * FROM manager where account='$account' and pass='$pass'";
	$test=mysql_query($sql);
	$chk2=mysql_fetch_row($test);
	if($chk2[0] == $account && $chk2[1] == $pass &&  $chk2[0] !='' && $chk2[1] !='' )
	{
		if($in !='')
		{
			$_SESSION['valid_account'] = $account;
			$_SESSION['valid_admin'] = $_POST["select"];
		}
?>
		<script>
		parent.mainFrame.location.href="writeasset.php";
		location.href="../index.php";
		</script>
<?
	}
	if($account =='' || $pass =='')
	{
		echo "請輸入帳號密碼,系統自動返回";
		header("refresh:1 ; url=../left0.php");
	}
	else
	{
		echo "帳號密碼有誤,系統自動返回";
		header("refresh:1 ; url=../left0.php");
	}			
}
}

if($logout !='')
	{
	//儲存起來,以便驗證使用者是否已登入
	unset($_SESSION['valid_account']);
	unset($_SESSION['valid_compiler']);
	unset($_SESSION['valid_admin']);
?>
	<script>
	parent.mainFrame.location.href="out.php";
	location.href="../left0.php";
	</script>
<?			
	}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>elearning</title>
</head>
<body>
<div align="center"><a href="left1.php" target="mainFrame"></a></div>

因為我的mysql 和 phpmyadmin 和appserv開安裝的 在測試登入時會顯示帳密輸入錯誤!!但在沒有分開安裝的電腦 測試沒問題

原始討論: http://twpug.net/x/modules/newbb/viewtopic.php?topic_id=2137

評論

Sign In or Register to comment.