-2
如何解碼$_get
變量使用PHP與出表單的方法?如何解碼獲取變量在PHP
HTML代碼
<a id="msgr"name="msgr<?php echo $d['qid'];?>"href="Chatbox.php">message</a>
PHP代碼(chatbox.php)
if(isset($_get["msgr"])){
$get_id=mysqli_fetch_array(mysqli_query($connection,"SELECT MAX(qid)
FROM `queries` WHERE uid='".$_SESSION['id']."'"));
$result = mysqli_fetch_array(mysqli_query($connection,"SELECT * FROM
`queries` where qid='".$get_id[0]."'"));
}
我怎樣才能像URL example.com/chatbox.php?qid=212 ? 請給予解釋並給我解決方案。在此先感謝
'$ _GET'不存在。然而'$ _GET'確實是 – RiggsFolly
'$ _GET'變量是基於查詢字符串內容作爲關聯數組填充的。這可以通過提交表單或使用查詢字符串設置URL來完成。你在這裏沒有做這些事情。 – apokryfos
你的腳本存在[SQL注入攻擊]的風險(http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) 即使[如果你正在逃避輸入,它不安全!](http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string) 使用[編寫的參數化語句](http:// php。淨/手動/ EN/mysqli.quickstart.prepared-statements.php) – RiggsFolly