Undefined index error PHP

前端 未结 9 875
春和景丽
春和景丽 2020-12-01 08:24

I\'m new in PHP and I\'m getting this error:

Notice: Undefined index: productid in /var/www/test/modifyform.php on line 32

Notice: Undef

9条回答
  •  死守一世寂寞
    2020-12-01 08:48

    There should be the problem, when you generate the

    . I bet the variables $name, $price are NULL or empty string when you echo them into the value of the field. Empty input fields are not sent by the browser, so $_POST will not have their keys.

    Anyway, you can check that with isset().

    Test variables with the following:

    if(isset($_POST['key'])) ? $variable=$_POST['key'] : $variable=NULL

    You better set it to NULL, because

    NULL value represents a variable with no value.

提交回复
热议问题