I tought you forgot to initializae the $obligatoryFieldNotPresent variable, as PHP create variables when they are initialized, the $obligatoryFieldNotPresent variable is created inside the if. $obligatoryFieldNotPresent = 0; if (strlen($_POST["titleIN"]) == 0 ) { $obligatoryFieldNotPresent = 1; } elseif (strlen($_POST["first_nameIN"]) == 0 ) { $obligatoryFieldNotPresent = 1; } elseif (strlen($_POST["publisherIN"]) == 0 ) { $obligatoryFieldNotPresent = 1; } elseif (strlen($_POST["copyrightIN"]) == "" ) { $obligatoryFieldNotPresent = 1; } elseif (strlen($_POST["ISBNIN"]) == 0 ) { $obligatoryFieldNotPresent = 1; } elseif (strlen($_POST["languageIN"]) == 0 ) { $obligatoryFieldNotPresent = 1; } elseif (!empty($_POST['categoriesIN'])) { $obligatoryFieldNotPresent = 0; } -- Davi R. Tavares