function ValidateRegister ($email, $password1, $password2) { $return = array (); if (empty ($email) || empty ($password1) || empty ($password2) || ($password1 != $password2) || !is_valid_email($email)) { $return ['result'] = false; $errors = array (); if (empty ($email)) $errors [] = "Missing E-Mail Address"; if (!is_valid_email($email)) $errors [] = "Invalid E-Mail Address"; if (empty ($password1)) $errors [] = "Missing Password"; if (empty ($password2)) $errors [] = "Missing Password Verification"; if ($password1 != $password2) $errors [] = "Passwords do not match"; if (count($errors) > 0) { $return ['error'] = "<b>Error</b>: " . implode (", ", $errors); return $return; } } $password = Encryption::EncryptHash (ENCRYPTION_TYPE, $password1); $result = Database::FetchRow ("SELECT id, email, password FROM accounts WHERE email = '$email'"); if ($result) { $return ['result'] = false; $return ['error'] = "Account already exists with that email"; return $return; } if (!Account::Register ($email, $password)) { $return ['result'] = false; $return ['error'] = "Unknown error during Registration"; return $return; } $return ['result'] = true; return $return; }