You need to put you iphone in a state known as DFU mode.
To do this,
you should first connect your phone to your computer and start iTunes.
Now hold down both the power and home buttons and wait for 10 seconds,
then let go of the sleep button and keep holding down the home button until you see a message about entering the Recovery Mode.
Then hit the restore button in Itunes and you should be fine.
If this doesn`t work after a few attempts,
call up Apple customer service and explain your situation.
They may send you a replacement if your phone is a lemon.