Samsung phone keeps restarting
First solution : Since you tried both wiping all data and only the cache the only thing as far as I know left to do is to install either a backed up rom you made earlier or install a fresh official one from the manufacturer's site(samsung in your case) trough recovery mode.

Second solution: 
Try to wipe manually(this solution is assuming you use windows)


Visit the Android Developers site to download the Android System
Development Kit (see Resources). Right-click the ZIP archive and
choose “Extract All.” Click “Browse” and choose your “C:\Program
Files” directory.
Click the folder you extracted and press “F2” to rename it. Give the
folder a simple, descriptive name, such as “AndroidADT.”
Right-click “Computer” in your file browser and choose “Properties.”
Click “Advanced System Settings” and, in the System Properties
window, click “Environment Variables.”
Click “Path” and “Edit” in the System Variables window. When the Edit
System Variable window opens, your path variable is selected, so
press “End” to move the cursor to the end of the selection. If you
type while the path is selected, you'll erase your path variable.
Type “;C:\Program Files\AndroidADT\sdk\platform-tools\” (without
quotes here and throughout) and ensure that you include the semicolon
at the beginning of the path. Click “OK” to save your changes.
Point your cursor to the upper-right corner of the screen and click
“Search.” Type “cmd” in the Search box and click the program icon in
the search results to launch the Command Prompt window.
Turn on your Android phone and connect it to a USB port on your
computer. Type “adb shell” and press “Enter.” When ADB connects to
your device, type “--wipe_data” and press “Enter.” Your phone
restarts in recovery mode and restores Android to factory settings.