我有一个论坛,用户可以填写 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 />
出于某种原因,cat 类别没有出现在 $_POST['cat'] 中;你能只有一组单选按钮吗?
最佳答案
你有一些错误输入。
value"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" />
关于php - HTML 单选按钮未显示在 $_POST 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1776714/