What common mistake does the user in the forum thread make when using echo in PHP?

The common mistake the user makes when using echo in PHP is not properly escaping user input, which can leave the application vulnerable to cross-site scripting (XSS) attacks. To solve this issue, it is important to always sanitize and escape user input before outputting it using echo to prevent malicious code injection.

// Incorrect usage without escaping user input
$userInput = $_GET['input'];
echo $userInput;

// Corrected code with proper escaping
$userInput = $_GET['input'];
echo htmlspecialchars($userInput, ENT_QUOTES, 'UTF-8');