What potential pitfalls should be considered when using HTML forms with PHP for user input?
One potential pitfall when using HTML forms with PHP for user input is the risk of SQL injection attacks if user input is not properly sanitized. To prevent this, always use prepared statements or parameterized queries when interacting with a database to avoid executing malicious SQL code.
// Example of using prepared statements to prevent SQL injection
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = ?");
$stmt->execute([$username]);