/** * Confirm user account by hash. */ static function confirm_account() { # hash GET param exists if ($hash = data('hash')) { $hash = confirm_account($hash); if ($hash === -3) { flash('Algo ocorreu errado. Tente novamente mais tarde..', 'error'); } else { if ($hash === true) { flash('Conta Confirmada! Agora você já pode se conectar.'); } } } go('/'); }
$confirmation = $confirmation_query->fetch(PDO::FETCH_ASSOC); return $confirmation; } function confirm_account($dbh) { $acc_confirm = $dbh->prepare("UPDATE registration SET is_confirmed = 1 WHERE confirmation_code = :confirmation_code"); if ($acc_confirm->execute(array(':confirmation_code' => $_GET["confirmation_code"]))) { return true; } else { return false; } } if (isset($_GET["confirmation_code"]) and !empty($_GET["confirmation_code"])) { if (get_confirmation_code($dbh)["confirmation_code"] == $_GET["confirmation_code"]) { if (get_confirmation_code($dbh)["is_confirmed"] == 0) { if (confirm_account($dbh)) { echo "account confirmed"; } else { echo "account couldnt be confirmed"; } } else { echo "account already comfirmed"; //header("location: ../error_page.php"); } } else { echo "invalid confirmation code"; //header("location: ../error_page.php"); } } else { echo "confirmation parameter missing or empty"; //header("location: ../error_page.php");