0) { Headers::redirect("../register"); return; } $db = DB::openConnection(); try { $guid = guidv4(); $stmt = $db->prepare($insertUserQuery); $stmt->bindValue(":USR", $username); $stmt->bindValue(":PAS", password_hash($password, PASSWORD_DEFAULT)); $stmt->bindValue(":EMA", $email); $stmt->bindValue(":COD", $guid); $stmt->execute(); mail( $email, "Account activation GuestBookDB", "Hello $username. To activate your account, visit https://userpage.fu-berlin.de/khofmann/phpCourse/tasks/guestBookDB/confirm?c=$guid" ); array_push($_SESSION["message"], "Please confirm your account using the mail we sent you."); } catch (PDOException $e) { if ($e->getCode() === "23000") { array_push($_SESSION["error"], "A user with this username or email already exists"); } else { array_push($_SESSION["error"], "SQL Error: {$e->getMessage()}"); } Headers::redirect("../register"); return; } DB::closeConnection($db); Headers::redirect("../login");