初学者在线急等关于checkbox的问题
我在index.php文件中如下使用的checkbox:
<tr>
<td><input type="checkbox" name="fiction" value="1">Fiction</td>
<td><input type="checkbox" name="horror" value="1">Horror</td>
</tr>
<tr>
<td><input type="checkbox" name="action" value="1">Action</td>
<td><input type="checkbox" name="comedy" value="1">Comedy</td>
</tr>
<tr>
<td><input type="checkbox" name="thriller" value="1">Thriller</td>
</tr>
我在confirm.php文件中引用此处变量的代码如下:
<?php
if( $_POST['fiction'] )
{
echo "fiction <br>";
}
if( $_POST['horror'] )
{
echo "horror <br>";
}
if( $_POST['horror'] )
{
echo "action <br>";
}
if( $_POST['comedy'] )
{
echo "comedy <br>";
}
if( $_POST['thriller'] )
{
echo "thrillers <br>";
}
?>
我如果把全部都选上的话就没有什么错误,如果哪个不选,就会出现如下错误(比如说fiction这个没有选的话):
Notice: Undefined index: fiction in c:\inetpub\wwwroot\confirm.php on line 174
请问一下这个是什么原因,谢谢了!