recaptcha_secret); $username = $_POST["username"]; $email = $_POST["email"]; $password = $_POST["passwd"]; if (isset($_POST["fullname"])) { $full_name = $_POST["fullname"]; } else { $full_name = null; } // TODO: we should really filter/validate g-recaptcha-response (still need to do) $recaptcha_resp = $_POST["g-recaptcha-response"]; // XXX: one downside of this is it checks the captcha before validating all the other fields, might want to move captcha validation to register() $resp = $recaptcha->verify($recaptcha_resp); $captcha_valid = $resp->isSuccess(); $reg_successful = false; if ($captcha_valid) { try { // TODO: validate_email (5th arg) $db->register($username, $email, $password, $full_name, true, $twig); $reg_successful = true; $success_alerts[] = 'Registration successful, Click here to return to the webapp'; } catch (RegistrationError $re) { $reg_successful = false; $error_text = $re->reason; $danger_alerts[] = $error_text; if ($db->conn->inTransaction()) $db->conn->rollBack(); } } else { $danger_alerts[] = "Captcha Invalid, please try again."; } } // TODO: move into a util file echo $twig->render("register.tmpl", array( "danger_alerts" => $danger_alerts, "success_alerts" => $success_alerts, "sess_info" => $sess_info )); ?>