<!-- script set on forum submission --> <?php require_once 'php/InitFiles/Init.php'; // validate on submission if (ForumInput::forumExists($POST)) { if (Token::check(ForumInput::getForumInput('token'))) { // validate user input $validateRegistry = new ValidateUserInput(); $passed = $validateRegistry->validateForum($_POST, ValidateUserInput::registryRequirements()); if ($passed->getValidForum()) { // register user into database $salt = HashGenerator::createSalt(32); $newUserSession = new UserSession(); $newUserSession->registerUser(array('firstname' => ForumInput::getForumInput($FIRSTNAME), 'lastname' => ForumInput::getForumInput($LASTNAME), 'email' => ForumInput::getForumInput($EMAIL), 'salt' => $salt, 'password' => HashGenerator::createHash(ForumInput::getForumInput($PASSWORD), $salt), 'datejoined' => date('Y-m-d H:i:s'), 'gender' => substr(ForumInput::getForumInput($GENDER), 0, 1))); RedirectPage::to('index.php'); } else { print_r($validateRegistry->getErrors()); echo "Please Try again"; } } else { // cross site request forgery } } ?> <!-- Sign-Up--> <!-- Front-end --> <!DOCTYPE html> <html> <head> <title>Sign Up</title>
<?php require_once 'php/InitFiles/Init.php'; if (ForumInput::forumExists($POST)) { $validateLogin = new ValidateUserInput(); $passed = $validateLogin->validateForum($_POST, array('email' => array('required' => true), 'password' => array('required' => true))); if ($passed->getValidForum()) { $user = new UserSession(); $login = $user->login(ForumInput::getForumInput($EMAIL), ForumInput::getForumInput($PASSWORD)); if ($login) { RedirectPage::to('index.php'); } else { echo "please check your email and password again"; } } else { print_r($passed->getErrors()); } } ?> <form action="" method="post"> <div class=""> <label for="email">Email</label> <input autocomplete="off" type="text" name="email" id="email"> </div> <div class=""> <label for="password">Password</label> <input autocomplete="off" type="password" name="password" id="password"> </div> <input type="submit" value="Log In"> </form>