Beispiel #1
0
            }
            if ($users->checkuser($email, 2)) {
                $usernameregistererror = true;
                $emailerror = 'E-mail already exists';
            }
            if (!$usernameregistererror) {
                // if check is OK !
                // Addition Into DB !!
                $query = "INSERT INTO users VALUES(NULL,'{$username}','{$email}','{$password}','{$firstname}','{$lastname}','{$birthdate}')";
                $user['username'] = $username;
                $user['password'] = $password;
                $user['email'] = $email;
                $user['firstname'] = $firstname;
                $user['lastname'] = $lastname;
                $user['birthdate'] = $birthdate;
                $users->register($user);
            }
        } else {
            $terms = "Please read and accept the terms first";
        }
    }
}
?>
            <!--                        Form Decomposition START !!!-->
            
                <font2>The required fields are marked with "*"</font2><br>
                <input class='input' type="text" name="username" placeholder="Username"/> *<br> <?php 
echo "<font>" . @$usernameerror . "</font>";
?>
<br>
                <input class='input' type="email" name="email" placeholder="E-mail"/>*<br>  <?php 
Beispiel #2
0
    if (strlen($_POST['last_name']) > 35) {
        $errors[] = 'Your last name must be less than 35 characters.';
    }
    $postElements = array("Username" => $_POST['username'], "Password" => $_POST['password'], "First name" => $_POST['first_name'], "Last name" => $_POST['last_name'], "Email" => $_POST['email'], "Confirmation Password" => $_POST['confirm_password']);
    foreach ($postElements as $identifier => $postElement) {
        if (empty($postElement) == true) {
            $errors[] = 'You haven\'t filled in the ' . $identifier . ' field.';
        }
    }
    //Error displayer
    if (empty($errors) == false) {
        echo '<p>' . implode('</p><p>', $errors) . '</p>';
    }
    //Checking if error array is empty
    if (empty($errors) == true) {
        //Assign post variables and stripping
        $username = htmlentities($_POST['username']);
        $password = $_POST['password'];
        $email = htmlentities($_POST['email']);
        $first_name = htmlentities($_POST['first_name']);
        $last_name = htmlentities($_POST['last_name']);
        //Register function
        users::register($first_name, $last_name, $username, $password, $email);
        //Header change for sucessful sign up
        header('Location: register.php?success');
        exit;
    }
}
if (isset($_GET['success']) && empty($_GET['success'])) {
    echo 'You have signed up successfully, feel free to login <a href="login.php">here</a>.';
}