What common mistake is highlighted in the provided PHP code related to form submission?

The common mistake highlighted in the provided PHP code related to form submission is that the form data is not sanitized before being used in the SQL query, leaving the application vulnerable to SQL injection attacks. To solve this issue, it is important to sanitize the form data using functions like mysqli_real_escape_string() or prepared statements to prevent SQL injection.

<?php
// Get form data and sanitize it
$username = mysqli_real_escape_string($conn, $_POST['username']);
$password = mysqli_real_escape_string($conn, $_POST['password']);

// Prepare and execute SQL query using sanitized data
$sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$result = mysqli_query($conn, $sql);

// Rest of the code
?>