I deployed this code on this page : http://flasharabia.com however the code doesn't seem to work ..
If you want to check the functionality - it would be far more responsible to use a non-destructive USSD code. e.g. *#06# displays the phone's IMEI number
The factory reset appears to be the only USSD "auto dialled" code that doesn't begin with *#. Which is rather unfortunate.
Edit: Actually, the IMEI code works on the Galaxy S2 running 2.3 (just tested) but not the Galaxy S3 running 4.0. My above comment refers to the S3.