The first thing to try is the automatic recovery solution. Enter the security code a few times in a row without pause between entries, and the phone will suggest an alternative way to remove the code. If it doesn't work, use the Factory Reset option available through Recovery (Volume Up + Power + Home or Volume Up + Power). Another solution is to visit a local phone service, they might fix it for you without losing the data.