<link type=text/css" rel="stylesheet" href="style/SecretStyles.css" />
    </head>
    <body>
        <div class="container">
            <h1>Reset your Password</h1>

            <?php 
// Once the form is submitted and the email passes the validation
//check to see if the email exists in the database
// if not then display that the email could not be found
//if the email exists
// then display that the email has been sent and wait 5 seconds before redirecting to index
if (!isset($_POST["resetForm"])) {
    loadForm(true);
} else {
    if (checkEmailRegex()) {
        // check the database to see if it exists
        //connect to database
        $db = new DbObject();
        //received email value from the page
        $email = $_POST['email'];
        //check email in db
        $results = $db->select("username", "Member", 'email="' . $email . '"');
        //stores the username in a variable for the storing of their resetID
        $user = getUsername($results);
        $email_exist = $results->num_rows;
        //records count
        //if returned value is more than 0, email exists
        if ($email_exist > 0) {
            // send an email and replace div
            if (sendMail($user)) {
                echo "<div>";
                $form->renderTextbox("txtQst2", "Enter another challenge question: ", true, 255, "", "");
                echo "</div>";
                echo "<div>";
                $form->renderTextbox("txtQst2Answer", "Answer: ", true, 255, "", "");
                echo "</div>";
            }
        }
    }
    $form->renderSubmitEnd("subRegisterSubmit", "Register");
}
//check to see if the form was submitted
if (isset($_POST["subRegisterSubmit"])) {
    //if the passwords do not match - or password is left blank - load the form again
    //with an error message. Send false indicating that the password check failed.
    if (!checkUsernameRegex() || !checkChallengeQuestions() || !checkEmailRegex() || !checkForEmptyFields() || !checkPasswordMatch()) {
        loadForm(false);
    } else {
        //load the form again
        loadForm(true);
        $passwordChecker = new PasswordChecker();
        $user = strip_tags($_POST["txtUsername"]);
        $email = strip_tags($_POST["txtEmail"]);
        $pwd = strip_tags($_POST["txtPassword"]);
        $qst1 = strip_tags($_POST["txtQst1"]);
        $qst1Answer = strip_tags($_POST["txtQst1Answer"]);
        $qst2 = strip_tags($_POST["txtQst2"]);
        $qst2Answer = strip_tags($_POST["txtQst2Answer"]);
        $success = $passwordChecker->addUser($user, $pwd, $email, $qst1, $qst1Answer, $qst2, $qst2Answer);
        if ($success) {
            $_SESSION["loggedIn"] = true;