What are the potential security risks associated with displaying user input directly in an input field in PHP?
Displaying user input directly in an input field in PHP can lead to security risks such as cross-site scripting (XSS) attacks. To mitigate this risk, it is important to properly sanitize and escape user input before displaying it in an input field.
<input type="text" name="username" value="<?php echo htmlspecialchars($_POST['username'] ?? '', ENT_QUOTES); ?>">