为何出现“未定义索引”错误

时间:2017-03-25 07:23:40

标签: php phpmyadmin

当我创建一个简单的学生注册页面时,我给这些字段提供了一些输入值,并试图通过使用POST来排除这些值。 但它显示“未定义的变量”

以下是制作简单学生注册表格的代码。

                            <head>

                                            <title>Student's Registration Form</title>

                            </head>

                            <body>
                                                                                                 学生登记表                                                                                                                                                   学生的姓名:                                                                                                                                                                                                    父亲的名字:                                                                                                                                                                                                    学校名称:                                                                                                                                                                                                    卷号:                                                                                                                                                                                                    类:                                                                                                                                                   选择班级                                                 第10                                                 9日                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
                            </body>

1 个答案:

答案 0 :(得分:0)

它未定义,因为你没有使用未定义的索引声明变量或访问数组。

您需要以

的形式访问数组元素
if (array_key_exists($key, $array)) {
  echo $array[$key];
}