2012-05-05 33 views
1

這是我正在發佈的單選按鈕形式的正確語法。表單工作正常,而不單選按鈕,它只有當我加入他們,我得到一個錯誤的說法,未定義的變量:where_to_search單選按鈕表單不發送數據。什麼是正確的語法?

<form action="" method="POST" > 

<div class="control-group"> 
    <label class="control-label">Search By:</label> 
     <div class="controls"> 
      <label class="radio"> 
       <input type="radio" name="where_to_search" id="optionsRadios1" value="1" checked> 
        Group Name 
      </label> 
       <label class="radio"> 
      <input type="radio" name="where_to_search" id="optionsRadios2" value="2"> 
        Group Description 
       </label> 
      </div> 
    </div> 


<input class="span2" name="keywords" id="appendedPrependedInput" size="15" placeholder="Search groups.." type="text"/><button class="btn" value="Go" type="submit">Go!</button> 




</form> 
+2

這是什麼'的var_dump($ _ POST)'顯示此腳本?一切看起來在你的標記是正確的。 –

+2

發佈您的PHP代碼。你不會得到一個未定義的變量通知,你可能會得到一個未定義的索引通知,除非你期望register_globals處於打開狀態。 –

+0

讓它工作! – arboles

回答

1

嘗試:檢查=「檢查」和<輸入類型=「提交」

+0

我同意'',但我不認爲'checked =「選中」'會有幫助。 –

0

您需要參考使用$ _ POST變量:

$_POST['where_to_search'] 
+1

沒有張貼任何PHP代碼,你怎麼知道OP還沒有這樣做? –

+1

因爲他說未定義的變量,而不是未定義的索引。 –

+1

是的,根據我上面的評論。但沒有任何事實回答的點點。 –