可能重複:
PHP: 「Notice: Undefined variable」 and 「Notice: Undefined index」未定義指數PHP
美好的一天!
我有下面的錯誤在我的代碼:
<?php
if (!$_POST['SUBMIT']){ //ERROR: Undefined index
?>
<H2>Add Employee</H2>
<form action="<?php print $_SERVER['PHP_SELF']; ?>" method="POST">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">SSN</td>
<td><input name="SSN" type="text" id="SSN"></td>
</tr>
<tr>
<td width="100"> </td>
<td><input name="SUBMIT" type="SUBMIT" id="ADD" value="ADD"></td>
</tr>
</table>
</form>
<?php
}
else {
//code here
}
?>
如何刪除上述錯誤?謝謝。
試着做一個'print_r($ _ POST)'或'var_dump($ _ POST)',看看陣列裏有什麼 – kjy112 2011-04-15 12:48:04
嘗試使用'isset()'和'!empty'而不是'!$ _ POST'。 – Robik 2011-04-15 12:49:09
@ kjy112 Array() – newbie 2011-04-15 12:49:21