There's a difference between between a passCODE which is a four or six digit code used to unlock a mobile device after you turn it on (or other services on a mobile device), and a passWORD which is what is used to log into your Apple ID account which may be required in resetting a forgotten passCODE. I am not clear as to which you are referring.
Read the Apple Support document for what to do if you forgot the passCODE on an iPhone or iPad. Click here then select your device type if necessary --> If you forgot your iPhone passcode or your iPhone is disabled - Apple Support - Which one you can use depends upon your equipment configuration.
Also:
If you forgot your iPad passcode, use your Mac or PC to reset it - Apple Support
Read this support article for what to do if you forgot your Apple ID passWORD - If you forgot your Apple Account password - Apple Support
or go directly to this link --> http://iforgot.apple.com/
If you still need help this page provides country-specific Apple Support contact information ➞ Contact Apple for support and service - Apple Support
If you are dealing with a disabled phone because of a forgotten passcode you will have no option but to erase the iPhone. You can restore it from a backup you have been keeping all this time. You may be able to restore some data by signing into the iCloud based services again on the iPhone.