Re: [請益] 無法正常登入

看板PHP作者 (~*)時間16年前 (2009/07/31 14:53), 編輯推噓4(405)
留言9則, 4人參與, 最新討論串8/8 (看更多)
感謝 dinos clubflymf arrack大<_ _ > 問題解決了 正如dinos大所說的 register_global ....囧"" 我去查了一下linux上的php.ini register_global居然為Off.. 囧""" 後來改了on之後 程式都能夠正常執行 非常感恩各位 另外以下是register_global為off的情形 純脆想了解一下._.?a 我有 echo("select * from `admin` where `account`='$account' : and `password`= '$password'"); 的確沒錯 會出現 select * from `admin` where `account`='' and `password`='' 沒有取到值 後來我多加變成 $check=showsql("select * from `admin` where `account`='$account' and `password`= '$password'"); $account=mysql_real_escape_string($_POST['account']); $password=mysql_real_escape_string($_POST['password']); echo("select * from `admin` where `account`='$account' and `password`= '$password'"); 這樣輸入值就可以取出來了 不過另外有嘗試以這種方式 我改成 if($_POST){ $account=mysql_real_escape_string($_POST['account']); $password=mysql_real_escape_string($_POST['password']); $check=showsql("select * from `admin` where `account`='$account' and `password`= '$password'"); if(count($check)>0) { $_SESSION['admin']='test'; header("Location:aaa.php"); } } if($_SESSION['admin']=='test') header("Location:aaa.php"); 想讓他來抓取值 讓欄位等於$account和$password 來進行登入的話 他另外會出現 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in 似乎沒有辦法連到資料庫 這也是因為global的問題嗎._.?"a 如果改以arrack大所說變成 $account=mysql_real_escape_string($_POST['account']); 的寫法 要如何讓他欄位能夠等於所輸入的$account呢 上面的寫的方式問題是出在哪呢._.? 非常感謝個位<_ _> ※ 引述《arrack (Arrack Tseng)》之銘言: : ※ 引述《intangible (~*)》之銘言: : : 恩恩 謝謝<_ _> : : $check=showsql("select * from `admin` where `account`='$account' : : and `password`= '$password'"); : : echo count($check); : : } : 我的引言為何都是白色的=_+ 這樣看起來好奇怪 : 你先echo("select * from `admin` where `account`='$account' : and `password`= '$password'"); : 如果沒猜錯的話 : 應該是會出現 : select * from `admin` where `account`='' and `password`='' : 如果是這樣,表示你的account跟password根本沒有去取值 : 如果是表單就用 : $account=mysql_real_escape_string($_POST['account']);//簡易用法 : 取一下值在試試看 : 這跟php.ini的設定有關係~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.134.181.103

07/31 15:07, , 1F
你要先連線才能用mysql_real_escape_string
07/31 15:07, 1F

07/31 15:10, , 2F
register_global Off 是 PHP 5 的預設值
07/31 15:10, 2F

07/31 15:10, , 3F
這東西打開容易有安全性問題
07/31 15:10, 3F

07/31 15:12, , 4F
使用 $_POST 取值 不論On/Off 都不會有問題
07/31 15:12, 4F

07/31 15:46, , 5F
是阿,因為他會根據MYSQL SERVER 作微調
07/31 15:46, 5F

07/31 15:50, , 6F
不然你把mres(縮寫)改成addslashes
07/31 15:50, 6F

07/31 15:50, , 7F
register_global 打開的確有安全性上的問題
07/31 15:50, 7F

07/31 15:50, , 8F
應該是說有使用到這功能的網站
07/31 15:50, 8F

08/02 12:56, , 9F
恩恩 謝謝各位
08/02 12:56, 9F
文章代碼(AID): #1ASfJPC_ (PHP)
文章代碼(AID): #1ASfJPC_ (PHP)