Esempio n. 1
0
    header('Refresh: 5; url=inscription.php');
} else {
    //all is ok : success message / start session variable / add user in DB and redirect
    require_once "private/config.php";
    require_once "models/UserManager.class.php";
    $userManager = new UserManager($db);
    //Structure data
    $data = array();
    $data['id'] = null;
    //for the id
    $data['login'] = ucfirst(htmlspecialchars($_POST['login']));
    $data['pwd'] = sha1(htmlspecialchars($_POST['pwd']));
    $data['nom'] = htmlspecialchars($_POST['nom']);
    $data['prenom'] = htmlspecialchars($_POST['prenom']);
    $data['adresse'] = htmlspecialchars($_POST['adresse']);
    $newUser = new User($data);
    //verif if the user already exist
    if (!($currentUser = $userManager->verifConnexion($data['login'], $data['pwd']))) {
        //the user dos not exit; we can add it and continue
        $userManager->add($newUser);
        $errorView->successInscription();
        $errorView->redirection(5);
        $_SESSION['login'] = $data['login'];
        header('Refresh: 5; url=calendar.php');
    } else {
        $errorView->errorUserAlreadyExist();
        $errorView->redirection(5);
        header('Refresh: 5; url=inscription.php');
    }
}
$viewG->footer();