Kioskea
Recherche
Ask a question »

PHP - Notice: Undefined index

March 2015

$ _POST or $ _GET are two special functions of PHP that are used to get variables from a user-filled form. While using these functions, a user may encounter an error - Notice: Undefined index. This error can be avoided with the help of PHP isset (). This error will be notified, but that depends on the configuration of the server. Notice: Undefined index is a minor error and hence not notified by default. With the help of the error_reporting function, the type of error reported can be changed.

[PHP] Notice: Undefined index





When using $ _POST or $ _GET to retrieve the variables from a form, you may encounter this error:
Notice: Undefined index 'fields of the table' in 'path of  php file being executes' on line 'current line'     


To avoid this error, simply test whether the fields of the table were initialized with the function isset ().
// Before using $_POST['value']    
if (isset($_POST['value']))    
{    
          // Instructions if $_POST['value'] exist    
}    

This type of error is notified depending on the configuration of the server.
It is not notified by default as it is considered as a minor error, corresponding to the constant E_NOTICE.

You can change the types of errors reported with the error_reporting function.
For unlimited offline reading, you can download this article for free in PDF format:
Php-notice-undefined-index.pdf

See also

In the same category

Published by jak58 - Latest update by Paul Berentzen
This document entitled « PHP - Notice: Undefined index » from Kioskea (en.kioskea.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.