HTML单选按钮未显示在$ _POST中

时间:2009-11-21 20:42:37

标签: php mysql radio-button

我有一个论坛,用户填写了2个单独的单选按钮类别,他们可以填写。

Permissions: private <input type="radio" name="permissions" value="private" /> public <input type="radio" name="permissions" value="public"/><br />

Category: default <input type="radio" name="cat" value"default" /> sport <input type="radio" name="cat" value"sport" />school <input type="radio" name="cat" value"school" />geeky <input type="radio" name="cat" value"geeky" />misc <input type="radio" name="cat" value"misc" /> funny <input type="radio" name="cat" value"funny" /><br />

出于某种原因,类别的猫没有出现在$ _POST ['cat']中;你能只有一套单选按钮吗?

2 个答案:

答案 0 :(得分:4)

你有一些错误。

值“default”应为value =“default”。与整个第二行代码相同。属性和值之间没有等号(=)。

快速提示:请勿将所有<input />标记放在一行上。它们仍会显示在您网页的同一行,但在文本编辑器中编辑会更容易。说到这一点,如果你有一个带语法高亮的文本编辑器,你可能会遇到这个问题。我建议Notepad++Geany

Category: 
default <input type="radio" name="cat" value="default" /> 
sport <input type="radio" name="cat" value="sport" /> 
school <input type="radio" name="cat" value="school" /> 
geeky <input type="radio" name="cat" value="geeky" /> 
misc <input type="radio" name="cat" value="misc" /> 
funny <input type="radio" name="cat" value="funny" />

答案 1 :(得分:2)

确保这些字段在<form></form>标记内。

相关问题