//This var contains result message of CRUD action $actionMessage = ""; $typeMessage = ""; //Component Class Manager $configManager = new ConfigManager($pdo); //Action Add Processing Begin if ($action == "add") { if (!empty($_POST['indexContent'])) { $indexContent = htmlentities($_POST['indexContent']); $sliderType = htmlentities($_POST['sliderType']); $createdBy = $_SESSION['userAnnahdaSite']->login(); $created = date('Y-m-d h:i:s'); //create object $config = new Config(array('indexContent' => $indexContent, 'sliderType' => $sliderType, 'created' => $created, 'createdBy' => $createdBy)); //add it to db $configManager->add($config); $actionMessage = "Opération Valide : Config Ajouté(e) avec succès."; $typeMessage = "success"; } else { $actionMessage = "Erreur Ajout config : Vous devez remplir le champ 'indexContent'."; $typeMessage = "error"; } } else { if ($action == "update") { $idConfig = htmlentities($_POST['idConfig']); if (!empty($_POST['indexContent'])) { $indexContent = htmlentities($_POST['indexContent']); $sliderType = htmlentities($_POST['sliderType']); $updatedBy = $_SESSION['userAnnahdaSite']->login(); $updated = date('Y-m-d h:i:s'); $config = new Config(array('id' => $idConfig, 'indexContent' => $indexContent, 'sliderType' => $sliderType, 'updated' => $updated, 'updatedBy' => $updatedBy));