What are the potential pitfalls of using inline frames in PHP to display content based on a Get variable?

Using inline frames in PHP to display content based on a Get variable can potentially expose your application to security risks such as cross-site scripting (XSS) attacks. To mitigate this risk, you should properly sanitize and validate the Get variable before using it to load content into the inline frame.

<?php
// Validate and sanitize the Get variable before using it
if(isset($_GET['content']) && in_array($_GET['content'], ['page1', 'page2', 'page3'])) {
    $content = $_GET['content'];
} else {
    $content = 'default';
}

// Output the inline frame with the sanitized content
echo '<iframe src="' . $content . '.php"></iframe>';
?>