Your iPhone enables you to add a four-digit passcode which locks your phone to prevent unauthorised users from using your cell phone. When you enable the passcode, your iPhone prompts you to enter the four-digit code before you can unlock your phone. However, if you have forgotten the passcode and unable to use your iPhone, you can override the passcode using iTunes--the default iPhone management program.
Restore your iPhone back to the default settings to override the passcode. To do so, connect your iPhone to the computer using the USB cable that came with your phone and launch iTunes. iTunes displays your device in the left panel under "Devices."
Click your iPhone under "Devices" and click the "Summary" tab. Click the "Restore" button. Keeping in mind that restoring your iPhone back to the default settings deletes all the currently saved information. When prompted, click "Backup" to back up your iPhone.
Click "Restore" again and follow the final guided prompts to restore your iPhone back to the default settings. When the process completes, click "OK." You should see the "Connect to iTunes" message on your phone. Keep your iPhone connected to the computer until the "Connect to iTunes" screen goes away or you see "iPhone is activated" message on your phone.
Right-click your iPhone under "Devices" and click "Eject." Close iTunes and disconnect your iPhone from the computer. Your iPhone no longer prompts you to enter the passcode.