What are the potential issues with using special characters in the value attribute of an input tag in PHP forms?

Using special characters in the value attribute of an input tag in PHP forms can potentially lead to security vulnerabilities such as cross-site scripting (XSS) attacks. To prevent this, it is important to properly sanitize and escape user input before displaying it in the value attribute.

<input type="text" name="username" value="<?php echo htmlspecialchars($username); ?>">