我正在用 PHP 为我的网站创建一个搜索工具。基本上我有两个单选按钮,一个标记为“用户”,另一个标记为“主题”,其想法是用户将能够在我的网站中搜索用户或主题。
这是搜索表单的代码:
<form name = "search" action = "search_result.php" method = "get" style = "float:right;">
<input type = "text" name = "query" id = "query" maxlength = "100">
<br />
<p><label for = "user">Search users
<input type = "radio" name = "options" id = "user" value = "user">
</label>
<label for = "topics"> Search topics
<input type = "radio" name = "options" id = "topics" value = "topics">
</label></p>
<input type = "Submit" value = "Go">
</form>
我试过这种方法:
if($_GET['user']==checked)//Base on specific radiobutton and check if checked
我也试过这个:
if($_GET['options']=="users")//Base on grouped radiobuttons
但两者都没有奏效。如何检查 PHP 已检查了哪个按钮?回答时,请记住我没有使用 jQuery 的经验。