作者taipingeric (一隻羊)
看板PHP
標題[請益] 登入帳號密碼問題
時間Thu Aug 28 00:47:22 2008
以下是我的程式碼 問題在於我不管輸入正確或錯誤帳號密碼都直接跳 error.php
麻煩各位幫我看一下 感恩
------------------ main.html --------------
<html>
<body>
<?php
<form method = "post" name="login" action="check.php" >
<font color="#FFFFFF"><br>帳號 </font>
<input type=text name="id" size=10><B><font color="#FF0000">(學號
)</font></B><p>
<font color="#FFFFFF">密碼 </font><B>
<input type="password" name="password" size=10><p><font color="#FF0000">(身分
證英文字母+後四碼)</font></B><p>
<input type=submit name="b1" value="登入">
<input type=reset size="100" value="重填">
</form>
?>
</body>
</html>
------------------- check.php ----------------
<?php
session_start();
$id=$_POST['id'];
$password=$_POST['password'];
$ip = mysql_connect ("localhost") ;
mysql_select_db("test1");
$sql="select id from ntumesa WHERE id = '$id' AND password = '$password'";
$result = mysql_query($sql);
$nT = mysql_num_rows($result);
// 依檢查結果分別導向主作業畫面與錯誤警告畫面
if ( $nT >1) {
list($id) = mysql_fetch_row($result);
// 設定 session 變數之初值
session_register("ssnid");
session_register("ssnname");
$_SESSION['ssnid'] = $id;
$_SESSION['ssnname'] = $name;
Header("location:book.php");
exit;
}
else {
Header("location:error.php");
exit;
}
?>
---------------------
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.245.106
→ flamerecca :那個...不好意思 不然你希望他去哪裡? 08/28 01:11
→ taipingeric :阿 拍謝 是我不管輸入正確或錯誤的帳號密碼都跑到 08/28 01:14
→ taipingeric :error.php 那邊 08/28 01:15
※ 編輯: taipingeric 來自: 140.112.245.106 (08/28 01:15)
推 zusocfc :條件式改寫一下.. 08/28 01:16
→ taipingeric :可以麻煩樓上的大大說清楚一點嗎? 拍謝 超新手 > < 08/28 01:19
推 flamerecca : action="check.php" -> action="error.php" 08/28 01:58
→ flamerecca :不支倒是不是這樣... 08/28 01:59
→ taipingeric :這樣不是會直接到ERROR然後就沒有檢查帳密了嗎@@? 08/28 02:08
推 flamerecca :不然是要檢查後無論對不對都回到error? 08/28 02:57
→ taipingeric :檢查 對:到book.php 不對:到ERROR.PHP 08/28 03:06
※ 編輯: taipingeric 來自: 140.112.245.106 (08/28 03:07)
※ 編輯: taipingeric 來自: 140.112.245.106 (08/28 03:14)
→ taipingeric :囧 應該是CHECK是否 "=" 1 因為好像只會有一組 08/28 03:17
→ taipingeric :不起 我錯了 08/28 03:17
※ 編輯: taipingeric 來自: 140.112.245.106 (08/28 03:23)