Whether you're selling your iPhone or taking it for repair you should reset it to delete your accounts - including your Apple ID, Facebook, ebay, email and other accounts - and remove all your content including apps, photos and music. Here's how to reset an iPhone, iPad and iPod touch to factory settings.
Reset an iPhone or iPad using Settings, General, Reset, Erase all content and settings. You will be prompted to enter your passcode and Apple ID before the process completes. If your phone has locked up and you just want to restart it but none of the buttons work, then hold the power button and home button down at the same time until the device turns off and you see the Apple logo. Then let go and your phone or iPad will be back to normal.