case 'idUser': $boolError = verifyName($info); $error = 'Votre nom ne peut pas contenir de caractères spéciaux et d\'accent '; break; case 'idPoste': $boolError = verifyPhone($info); $error = 'Le numéro de poste doit être composé de 5 chiffres et commencé par 5 ou 9'; break; case 'idPavillon': $pavillon = verifyPavillon(substr($info, 0, 1)); $etage = verifyEtage(substr($info, 1)); $boolError = $pavillon && $etage; $error = "Le pavillon ou l'étage est incorrect"; break; case 'idLogiciel': $boolError = verifySoft($info); $error = "Le nom du logiciel ne peut pas contenir d'accents, ni de caractères spéciaux"; break; default: throw new Exception("ID NON VALIDE"); } if ($boolError === false) { sendError($error); } } else { sendError("Le champs est vide"); } /* * Cette fonction permet de retourner les erreurs */ function sendError($message)
require 'connexionBDD.php'; require 'fonctionBDDPavillon.php'; if (isset($_POST['nomUtilisateur'], $_POST['postePersonne'], $_POST['pavillonPersonne'], $_POST['ip'], $_POST['pc'], $_POST['typeProbleme'])) { //Informations renseignees par l'utilisateur $nomUtilisateur = verifyName($_POST['nomUtilisateur']); $telephone = verifyPhone($_POST['postePersonne']); $pavillon = verifyPavillon(substr($_POST['pavillonPersonne'], 0, 1)) && verifyEtage(substr($_POST['pavillonPersonne'], 1)) ? htmlspecialchars($_POST['pavillonPersonne']) : false; $service = !empty($_POST['service']) && isset($_POST['service']) ? getPavillonById(htmlspecialchars($_POST['service']), $connexion) : false; $thispc = isset($_POST['thispc']) ? true : false; $urgent = isset($_POST['urgent']) ? true : false; //Information retrouve automatiquement $ip = verifyIp($_POST['ip']); $pc = !empty($_POST['pc']) ? htmlspecialchars($_POST['pc']) : false; //Information sur le probleme $type = verifyTypeProbleme($_POST['typeProbleme']); $prob = isset($_POST['precisionProbleme']) && !empty($_POST['precisionProbleme']) ? htmlspecialchars($_POST['precisionProbleme']) : false; $complement = isset($_POST['complement']) && !empty($_POST['complement']) ? htmlspecialchars($_POST['complement']) : ''; $logiciel = ''; if (isset($_POST['nomLogiciel'])) { $logiciel = verifySoft($_POST['nomLogiciel']); } if (!$nomUtilisateur || !$telephone || !$pavillon || !$ip || !$pc || !$type || !$prob || $logiciel === false || !$service) { redirect('/incident/declaration.html'); } else { $sujet = sujetProbleme($pc, $type, $thispc); echo $corpsMail = formeHtml($nomUtilisateur, $telephone, $pavillon, $service, $ip, $pc, $type, $prob, $complement, $logiciel, $thispc, $urgent); //mailto(SMTP,PORT,MAIL_FACULTATIF,MAIL_ASSISTANCE,$sujet,$corpsMail); //config.php } } else { redirect('/incident/declaration.html'); }