php 在接收下拉列表的值时出现问题,错误提示是 Undefined index。请指出错误在哪里呢?

Html文件如下:
<form action="receiptlist.php?act=sname" name="listForm" method="post">
供应商:
<select name="PurchaseID">
<option value="0">请选择...</option>
<option value="1" >广州市超电电气有限公司</option>
</select>
<input type="submit" value="确定" />
</form>
php文件如下:
if($_GET['act'] == 'sname'){
$act = 'sgoods';
$PurchaseID = $_POST['PurchaseID'];
}
错误提示如下:
<b>Notice</b>: Undefined index: PurchaseID in <b>C:\AppServ\www\SuperMarket\admin\stoct\receiptlist.php</b> on line <b>15</b><br />

改为
if(!empty($_POST['PurchaseID']){
$PurchaseID = $_POST['PurchaseID'];
}追问

用print_r($_POST)检查有关变量是否有错,得出:
Array ( [PurchaseID] => 1 ),那么变量名称是没有。

温馨提示:答案为网友推荐,仅供参考
相似回答