} if (isset($_POST['country'])) { $country = safeString($_POST['country']); } if ($country == "") { array_push($errors, 'Country can not be blank.'); } if ($password != $confirm_password) { array_push($errors, 'Passwords do not match'); } $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if ($resp->is_valid) { if (count($errors) == 0) { if (register($email, $first_name, $last_name, $password, $street, $city_state, $country)) { $registered = true; } elseif (!assertUserDoesNotExists($email)) { array_push($errors, 'An account already exists with your email address.'); } } } else { array_push($errors, 'You failed the reCAPATCHA test. Are you sure you\'re human?'); } } if (!$registered) { $smarty->assign('recapatcha', recaptcha_get_html(RECAPTCHA_PUBLIC, $error)); } else { $session->login($email, $password); } $smarty->assign('errors', $errors); $smarty->assign('registered', $registered); $smarty->assign('email', $email);
function register($email, $firstName, $lastName, $password, $street, $city, $country) { global $db; if (assertUserDoesNotExists($email)) { $auth = uniqid(); $work = createUser($auth, true, $firstName, $lastName, $password, $email, $street, $city, $country, false); if ($work) { sendWelcomeEmail($email, $firstName, $lastName); return $work; } } return false; }