dounouxi1020 2011-04-15 12:46
浏览 36
已采纳

PHP中未定义的索引[重复]

Possible Duplicate:
PHP: “Notice: Undefined variable” and “Notice: Undefined index”

Good day!

I am having the following error in my code:

<?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">&nbsp;</td>
            <td><input name="SUBMIT" type="SUBMIT" id="ADD" value="ADD"></td>
       </tr>
    </table>
    </form>
 <?php
    }
    else {
    //code here
    }
?>

How can I remove the error above? Thank you.

  • 写回答

4条回答 默认 最新

  • doubi4617 2011-04-15 12:50
    关注

    It should be a notice and not an error.

    To fix is you'll have to check whether $_POST['submit'] is set:

    if(!isset($_POST['submit'])) {
        ...
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程