PHP - Notice: Undefined index

December 2016

$ _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.

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.

Related :

This document entitled « PHP - Notice: Undefined index » from CCM ( 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.