What are the potential security risks of allowing a user to embed external content on their website using PHP?

Allowing a user to embed external content on their website using PHP can pose security risks such as cross-site scripting (XSS) attacks, remote code execution, and data injection. To mitigate these risks, it is important to validate and sanitize any user input before displaying it on the website.

// Validate and sanitize user input before embedding external content
$user_input = $_POST['user_input'];
$filtered_input = filter_var($user_input, FILTER_SANITIZE_STRING);
echo $filtered_input;