Php 为<;选择>;标签

Php 为<;选择>;标签,php,html,Php,Html,我试图从标签中获取$\u POST['category'],但它是空的 HTML <form name="report" method="post" action=""> <table border="1"> <tr> <th>Category</th> <th> <select name="category" form="report">

我试图从
标签中获取
$\u POST['category']
,但它是空的

HTML

<form name="report" method="post" action="">
<table border="1">
    <tr>
        <th>Category</th>
        <th>
            <select name="category" form="report">
                <option value="one">Option 1</option>
                <option value="two">Option 2</option>
            </select>
        </th>
     </tr>
</table>
</form>

一旦提交,页面就为空(死在一个空变量中)。相同形式的其他变量工作正常(如
)。我使用的是PHP5.2.17

您的问题缺少提交按钮,但您需要这样做:

<form name="report" method="POST">
<table border="1">
    <tr>
        <th>Category</th>
        <th>
            <select name="category" form="report">
                <option value="Option 1" title="Option 1">Option 1</option>
                <option value="Option 2" title="Option 2">Option 2</option>
            </select>
        </th>

        <input type='submit' name='submit' value='submit' />

     </tr>
</table>
</form>

类别
选择1
选择2

$\u POST['submit']
未设置,因为表单没有名为submit的输入元素。这导致
die($\u POST['category'])
无法执行。这会导致PHP脚本不产生任何输出。

您的代码没有提交按钮。这通常会有所帮助。表单属性通过id而不是名称引用表单,并且select已经在表单中…我的意思是,属性
form=“id-of-a-form”
通过其id引用表单。@JoshuaGeorge使用提交输入更新您的问题,您确定它在
中吗?@zamnuts属性是html5
<form name="report" method="POST">
<table border="1">
    <tr>
        <th>Category</th>
        <th>
            <select name="category" form="report">
                <option value="Option 1" title="Option 1">Option 1</option>
                <option value="Option 2" title="Option 2">Option 2</option>
            </select>
        </th>

        <input type='submit' name='submit' value='submit' />

     </tr>
</table>
</form>