How to completely reset an iphone?

My girlfriend recently bought her friends old iphone. Her friend doesn't remember her iTunes account password or the password for the email it's under, so we can't reset the phone and erase the content. We tried signing in on a new account but it still asks for the one for her friends account instead of the new account. So my question is, how can I reset an iphone 4 without knowing the iTunes password?

Do a factory reset in settings. Same thing happened to a friend. It will be like a new phone basically after that.

Connect to itunes and restore it thats it

You have to get her friend to remove her iCloud account from the phone. Connecting it to iTunes and doing a factory restore won't work.