Skip to content
PHP Logo

What are some potential pitfalls of using iframes to load PHP files in an HTML document?

Using iframes to load PHP files in an HTML document can lead to security vulnerabilities such as cross-site scripting attacks if not properly sanitized. To prevent this, make sure to validate and sanitize any user input before displaying it in the iframe.

php
<?php
$filename = filter_input(INPUT_GET, 'file', FILTER_SANITIZE_STRING);
include($filename);
?>