I sold my phone to a friend. He need to erase content so he can use phone. I don't know if I gave him the correct password. If I change my apple password on my new phone will he be able to use it on my old phone to erase content as well?
Don’t give them your password. It’s not needed to erase the device as long as you still know your AppleID and password - the link at the bottom erases iPhones in recovery mode and they can do that without your secrets if they have physical custody of the device.
For you, this guide is your checklist - jump to the part where “you no longer have the device”.
The erase device (step one above) is a little easier on them if you trust them to know your old passcode but they can connect it to a computer and restore/erase it without knowing your passcode or your AppleID password.
If they don’t know your passcode, start here and work back up if needed