prepare("SELECT users.id AS id, users.is_verified AS is_verified FROM requests_register JOIN users ON users.id = requests_register.user WHERE requests_register.id = ?"); if (!$statement) { http_response_code(500); $errorMessage = "An unexpected error occurred while verifiying the account."; } else { $statement->bind_param('s', $_GET['id']); $statement->execute(); $result = $statement->get_result(); if (!$result) { http_response_code(500); $errorMessage = "An unexpected error occurred while verifiying the account."; $statement->close(); } else { $userData = $result->fetch_assoc(); $statement->close(); if (!$userData) { http_response_code(400); $errorMessage = "Invalid request ID."; } else { $verified = false; if ($userData['is_verified']) { $verified = true; http_response_code(400); $errorMessage = "The account is already verified."; } if (!$verified) { $statement = $connection->prepare("UPDATE users SET is_verified = 1 WHERE id = ?"); if (!$statement) { http_response_code(500); $errorMessage = "An unexpected error occurred while verifiying the account."; } else { $statement->bind_param('i', $userData['id']); if (!$statement->execute()) { http_response_code(500); $errorMessage = "An unexpected error occurred while verifiying the account."; } else { session_regenerate_id(true); $_SESSION['user'] = $userData['id']; } $statement->close(); } } } $statement = $connection->prepare("DELETE FROM requests_register WHERE id = ?"); if (!$statement) { http_response_code(500); $errorMessage = "An unexpected error occurred while verifiying the account."; } else { $statement->bind_param('s', $_GET['id']); if (!$statement->execute()) { http_response_code(500); $errorMessage = "An unexpected error occurred while verifiying the account."; } $statement->close(); } } } } if ($errorMessage) { $pageTitle = "Your account hasn't been verified"; $pageDescription = $errorMessage; } else { $pageTitle = "Your account has been verified"; $pageDescription = "Your account has been verified."; } include 'header.php'; ?>

Return to home