What are the potential pitfalls of using PHP with MySQL for password protection?

One potential pitfall of using PHP with MySQL for password protection is storing passwords in plain text in the database, making them vulnerable to security breaches. To solve this issue, passwords should be hashed before storing them in the database using a secure hashing algorithm like bcrypt.

// Hashing the password before storing it in the database
$hashed_password = password_hash($password, PASSWORD_DEFAULT);

// Storing the hashed password in the database
$query = "INSERT INTO users (username, password) VALUES ('$username', '$hashed_password')";
$result = mysqli_query($connection, $query);