What potential security risks are present in the PHP code provided for form submission?

The PHP code provided for form submission is vulnerable to SQL injection attacks due to directly inserting user input into the SQL query. To mitigate this risk, you should use prepared statements with parameterized queries to sanitize user input before executing the SQL query.

// Original vulnerable code
$username = $_POST['username'];
$password = $_POST['password'];

$sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$result = mysqli_query($conn, $sql);

// Fixed code using prepared statements
$username = $_POST['username'];
$password = $_POST['password'];

$stmt = $conn->prepare("SELECT * FROM users WHERE username=? AND password=?");
$stmt->bind_param("ss", $username, $password);
$stmt->execute();
$result = $stmt->get_result();