[請益] 將from中的資訊post到另一個網頁出了問題

看板PHP作者 (旅行)時間16年前 (2010/01/01 17:18), 編輯推噓5(508)
留言13則, 5人參與, 最新討論串1/1
大家好,我是PHP&mySQL的新手... 近期因為學校作業的關係要寫這類的程式 不過遇到一些問題想請教各位 這是我在serch.php下寫的程式: <form id="form1" name="form1" method="post" action="result.php"> <div align="center"><strong>miRNA name:</strong> <input name="name" type="text" id="textfield" value="" /> <input type="submit" name="button" id="button" value="Serch" /> </div> </form> 我想要把使用者打在name這個textfield的資訊傳到result.php做資料庫的搜尋之用 result.php下的程式: <? $link=mysql_connect("xxx","xxx","xxx"); mysql_select_db("aquila_bioinfo",$link); $str="select ID,target,date,reference from miRNA_hsa_disease where ID='$name'"; $list=mysql_query($str,$link); ?> 問題就是在serch.php中打的搜尋關鍵字無法傳到result.php下 所以都無法搜尋到結果 如果直接用$str="select ID,target,date,reference from miRNA_hsa_disease where ID='hsa-let-7a'"; 是沒問題的 所以我不曉得為什麼在serch.php中打的搜尋關鍵字無法傳到result.php下 是哪裡有寫錯嗎...@@? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 58.114.176.100

01/01 17:33, , 1F
對了 伺服器是自己架的 是用ubuntu9.10的LAMP
01/01 17:33, 1F

01/01 17:37, , 2F
你form是用get還是POST?..get請用$_GET['name']~
01/01 17:37, 2F

01/01 17:38, , 3F
POST用$_POST['name']
01/01 17:38, 3F

01/01 17:39, , 4F
建議你傳過來的東西處理過再query,防sql injection
01/01 17:39, 4F

01/01 17:48, , 5F
改成使用$_POST['name']就可以用了 感謝!!
01/01 17:48, 5F

01/01 17:49, , 6F
另外我在本機上使用appserv 舊方法可以跑
01/01 17:49, 6F

01/01 17:49, , 7F
看來是伺服器設定的問題 不曉得這兩的差別在哪裡..
01/01 17:49, 7F

01/01 17:52, , 8F
因為安全性的問題新版的register_globals都設成off
01/01 17:52, 8F

01/01 17:56, , 9F
大概了解是怎麼一回事了 感謝你!!
01/01 17:56, 9F

01/02 00:38, , 10F
$_REQUEST['name'] 可以省去更多麻煩 @@"
01/02 00:38, 10F

01/02 06:41, , 11F
樓上這樣可以用 GET 去亂搞 POST 變數 這似乎不太對勁...
01/02 06:41, 11F

01/02 09:01, , 12F
基本上不建議使用_REQUEST..除非是不重要的東西
01/02 09:01, 12F

01/02 12:06, , 13F
恩 樓上幾位是正確的 我只是想說學校交作業而已 沒啥差@@"
01/02 12:06, 13F
文章代碼(AID): #1BFRtmVe (PHP)
文章代碼(AID): #1BFRtmVe (PHP)