"Shuts off automatically after 5 seconds"
Your Mac tests your hard drive during startup, as part of the power-on-self-test (POST). If the hard drive does not pass, your Mac will try again. If no pass after 3 tests, your Mac will shut off.
If you can boot to single-user mode (boot while holding Command-S), you will see text scrolling down. You will see the command to type in the last couple of lines, so type: /sbin/fsck -fy
Press enter, and you should see a few lines for testing, and should end in a "test completed", or "Passed test", or something similar. If you get a line with errors, or telling you that there is a problem with the drive, then.... the drive is likely no good.