//echo ' in'; //echo $user->getUserStatus(); $user->setUserStatus(2); //echo 'in'; $userManager->save($user); //echo $user->getUserStatus().'in'; $message = new Alert("info", true); $message->addText('Thanks ' . $user->getFirstName() . '!</br>Your email is now confirmed. You can already login.'); $message->messageToSession(); //echo $user->getUserStatus().'should be there'; header('Location: index.php'); exit; //echo '</br> shouldnt be there'; } else { //user already confirmed $message->addText("Your account is already confirmed."); } } else { //confirmCode doesnt exist $message->addText("Your comfirm link is broken."); } $message->messageToSession(); header('Location: index.php'); exit; } else { //visitor goes on a wrong link $message = new Alert("danger", true); $message->addText("Your comfirm link is broken."); header('Location: index.php'); exit; }
//User doesn't exist yet, and data are checked //So we register user (userType 1,userStatus 1,..) $data = User::returnDataArrayFromData(1, 1, $email, $university->getId(), $firstName, $lastName, $passWord); $newUser = new User($data); $newUser->setEmailChecker(); $mailer->sendEmailVerify($newUser); if ($mailer->sendEmailVerify($newUser)) { $message = new Alert('info', true); $message->addText('Welcome <strong>' . $firstName . '</strong>! Before you log in, please confirm your email by clicking the link you received.'); $message->messageToSession(); $userManager->save($newUser); header('Location: index.php'); exit; } else { $message = new Alert('warning', true); $message->addText('Sorry <strong>' . $firstName . '</strong> we had a little problem! Please try again.'); $message->messageToSession(); } } else { //User exist already ( email already used) $message->addText('Email address already registered.'); } } //-------All fields are NOT correct OR user already registered -------- // From here, there was a problem with one of the field or user already registered // We show the form again, prefill in with error message //Save message to transmit it to page $message->messageToSession(); //Save correct fields to transmit to page $_SESSION['correctFields'] = $correctFields; createPage("register");
<?php /** * Created by PhpStorm. * User: Julien * Date: 29/01/16 * Time: 12:40 */ ?> <div class="container"> <?php //If user connects for the first time if ($user->getUserStatus() == 2) { $message = new Alert("success", false); $message->addText('<p>Welcome ' . $user->getFirstName() . '!</p><p>Before your registration is fully completed, we need few more details...</p>'); $message->show(); } ?> </div>
} else { $loginCorrect = false; $message->addText('Password is not valid.'); } //if the field content are correct, we check the user if ($loginCorrect) { $userManager = new UserManager($db); if ($userManager->getUniqueFromEmail($email) instanceof User) { $user = $userManager->getUniqueFromEmail($email); if ($user->getPassWord() == md5($passWord)) { //Email exists and password is the good one then check that user email is confirmed. if ($user->getUserStatus() >= 2) { //email is confirmed. $_SESSION['user'] = $user; $message = new Alert('info', true); $message->addText('Hello <strong>' . $user->getFirstName() . '</strong>!'); $message->messageToSession(); header('Location: index.php'); exit; } else { $message->addText('Please confirm your email address by clicking the link you received.'); } } else { $message->addText('Password invalid.'); } } else { $message->addText('Email address doesn\'t correspond to any users.'); } } $message->messageToSession(); createPage("home.visitor");