public function insCheck($smarty, $tpl, $params, $DB) { // Vérif formulaire inscription + envoi requête inscription si OK $inscription = new Register($DB); if (isset($_POST['signin'])) { // Si tous les champs sont remplis... if (isset($_POST['pseudo']) && $_POST['pseudo'] != '' && (isset($_POST['pwd']) && $_POST['pwd'] != '') && (isset($_POST['pwdConfirm']) && $_POST['pwdConfirm'] != '') && (isset($_POST['email']) && $_POST['email'] != '')) { if (strlen($_POST['pseudo']) < 6) { $smarty->assign('lengthPseudo', utf8_encode("Votre pseudo doit contenir 6 caractères minimum !")); $smarty->assign('nom', $_POST['nom']); $smarty->assign('prenom', $_POST['prenom']); $smarty->assign('mail', $_POST['email']); $smarty->display($tpl); } else { if (strlen($_POST['pwd']) < 6) { $smarty->assign('lengthPwd', utf8_encode("Votre mot de passe doit contenir 6 caractères minimum !")); $smarty->assign('nom', $_POST['nom']); $smarty->assign('prenom', $_POST['prenom']); $smarty->assign('mail', $_POST['email']); $smarty->display($tpl); } else { $login = trim(htmlentities($_POST['pseudo'])); $pwd = sha1($_POST['pwd'], $raw_output = false); $pwdC = sha1($_POST['pwdConfirm'], $raw_output = false); $nom = trim(htmlentities($_POST['nom'])); $prenom = trim(htmlentities($_POST['prenom'])); $mail = $_POST['email']; // Si les deux mots de passe ne correspondent pas... if ($pwd != $pwdC) { $smarty->assign('log', $_POST['pseudo']); $smarty->assign('nom', $_POST['nom']); $smarty->assign('prenom', $_POST['prenom']); $smarty->assign('mail', $_POST['email']); $smarty->assign('errPwd', "Les deux mots de passe saisis ne correspondent pas."); $smarty->display($tpl); } else { $pseudoCheck = $inscription->logCheck($login); $mailCheck = $inscription->mailCheck($mail); // Si requête pseudo renvoie un résultat -> Pseudo déjà utilisé if ($pseudoCheck) { $smarty->assign('nom', $_POST['nom']); $smarty->assign('prenom', $_POST['prenom']); $smarty->assign('mail', $_POST['email']); $smarty->assign('errLog', utf8_encode("Cet identifiant est déjà utilisé! Veuillez en saisir un autre.")); $smarty->display($tpl); // Si requête mail renvoie un résultat -> Mail déjà utilisé } else { if ($mailCheck) { $smarty->assign('log', $_POST['pseudo']); $smarty->assign('nom', $_POST['nom']); $smarty->assign('prenom', $_POST['prenom']); $smarty->assign('errMail', utf8_encode("Cette adresse email est déjà utilisée! Veuillez en saisir une autre.")); $smarty->display($tpl); // Sinon -> Inscription } else { $ins = $inscription->inscriptionMbr($login, $pwd, $nom, $prenom, $mail); $smarty->assign('login', $login); $smarty->display('index.tpl'); } } } } } // Si tous les champs ne sont pas remplis... } else { $smarty->assign('log', $_POST['pseudo']); $smarty->assign('nom', $_POST['nom']); $smarty->assign('prenom', $_POST['prenom']); $smarty->assign('mail', $_POST['email']); $smarty->assign('errIns', "Veuillez s'il vous plait remplir tous les champs."); $smarty->display($tpl); } } }