Exemplo n.º 1
0
$form->append($field);

$submit = $modules->get("InputfieldSubmit");
$submit->attr("value","Subscribe");
$submit->attr("id+name","submit");
$form->append($submit);
$form->processInput($input->post);
*/
if ($input->post->submit) {
    $email = $sanitizer->email($input->post->email);
    $username = $sanitizer->pageName($email);
    $firstname = $sanitizer->text($input->post->firstname);
    $lastname = $sanitizer->text($input->post->lastname);
    $password = $input->post->password;
    if (strlen($username) != 0) {
        if (username_validation($username) == 0) {
            //if (1==2) {
            //$username->error = " ";
            $err_count++;
            $errors[] = "That email address is already in use!";
        }
    }
    if (!$err_count) {
        $new_user = new User();
        $new_user->of(false);
        $new_user->name = $username;
        $new_user->email = $email;
        $new_user->pass = $password;
        $new_user->addRole("guest");
        $new_user->firstname = $firstname;
        $new_user->lastname = $lastname;
Exemplo n.º 2
0
function error_processing()
{
    /* --Old User Authentication-- */
    //Users should be a class? Or just SQL?
    //Users 'key' should be name for lookup purproses, perhaps.
    $user1 = array('username' => 'admin', 'password' => 'admin');
    $user2 = array('username' => 'user', 'password' => 'user');
    $users = array($user1, $user2);
    //Replace $users with db connection
    //Replace $users with db connection
    $form_data = $_POST;
    $errors = array();
    $blankness = "";
    $submitted_username = $form_data['username'];
    $submitted_password = $form_data['password'];
    function blank_form_detection($blankness_test)
    {
        foreach ($blankness_test as $key => $value) {
            if (empty($value)) {
                $blankness = true;
                return $blankness;
            }
        }
    }
    //Error Processing for No known User
    function username_validation($submitted_username_input, $users_input, $errors_input)
    {
        $submitted_username = $submitted_username_input;
        $errors = $errors_input;
        //Replace $users with db connection
        $users = $users_input;
        //Replace $users with db connection
        //Replace this validation
        if ($submitted_username != $users[0]['username'] && $submitted_username != $users[1]['username']) {
            $errors[] = "Username is not a valid username.";
        }
        //Replace this validation
        return $errors;
    }
    //Error Processing for User/PW don't match
    function user_validation($submitted_username_input, $submitted_password_input, $users_input, $errors_input)
    {
        $submitted_username = $submitted_username_input;
        $submitted_password = $submitted_password_input;
        $users = $users_input;
        $errors = $errors_input;
        if ($submitted_username == $users[0]['username'] && $submitted_password != $users[0]['password']) {
            $errors[] = "Username and password do not match.";
        }
        if ($submitted_username == $users[1]['username'] && $submitted_password != $users[1]['password']) {
            $errors[] = "Username and password do not match.";
        }
        return $errors;
    }
    $errors = username_validation($submitted_username, $users, $errors);
    $errors = user_validation($submitted_username, $submitted_password, $users, $errors);
    $blankness = blank_form_detection($form_data);
    $processed_errors = array($errors, $blankness);
    return $processed_errors;
}
Exemplo n.º 3
0
    redirect_to("not_found.php");
}
//Validation for register
if ($_POST['submit'] == "Register") {
    $username = mysql_prep($_POST['username']);
    $password = $_POST['password'];
    $confirm = $_POST['confirm'];
    $email = mysql_prep($_POST['email']);
    $location = mysql_prep($_POST['location']);
    $gender = mysql_prep($_POST['gender']);
    $month = mysql_prep($_POST['month']);
    $day = mysql_prep($_POST['day']);
    $year = mysql_prep($_POST['year']);
    $errors = array();
    //username validation
    foreach (username_validation($username) as $error) {
        $errors[] = $error;
    }
    //checks database if username is already in use
    connect_to_database();
    select_database();
    if (get_num_rows("users", "username", $username) != 0) {
        $errors[] = "Desired username is already in use. Please pick another one. NOTE: Username is not case sensitive.";
    }
    close_connection($connection);
    //password validation
    foreach (password_validation($password, $confirm) as $error) {
        $errors[] = $error;
    }
    //email validation
    foreach (email_validation($email) as $error) {