Its definitely hardware related.
Software could cause your PC to restart itself, but software cannot affect a PC that is switched off
So you when you tried to start it up, and it didn't... that shows that its a hardware problem.
Unfortunately, from what you've mentioned, it could be pretty much anything. There are several key components in a PC, and most of them can stop a PC from starting if they are faulty.
I don't think it would be an overheating problem by the way. Again, overheating can cause a PC to shut itself down (and then restart). But overheating would not stop a PC from starting up at all. Components take time to heat up, and then overheat.
My guess is the PSU (power supply unit), or possibly the motherboard. It could be other things too (like the processor/cpu or even the RAM), but the first two are my guess anyway. But I'm only basing that on experience, because there isn't really enough information to make any really good diagnosis.
The only thing that concerns me a bit, is that after shaking it, it started up. This could be a coincidence. And it could be that the PSU is on its way out, and the little shake helped shake some life into it one more time so that it worked. But really, shaking it and then it working... indicates that something is loose inside the PC. And the problem is that this could be almost any of the components or cables. The main problem though, is that unless you are experienced with PC's, it would impossible to really know what to do to fix it safely.
Usually I am determined to help someone, and would only suggest taking it to a local computer store, if I had absolutely exhausted every possible solution I could think of. But in this situation... I think that might actually be a good idea. If you can find a friendly local computer centre or something along those lines, you could try taking it too them to fix. Personally, I would suggest saying to them that you think something might be loose, and ask them to check. Someone who knows what they are doing, could do that in 5 minutes. Hopefully then, they could test the PC for you. If the PC seemed to work great... then its possible that was just the problem. They might even not charge you for that, if you are very lucky
Otherwise, if the PC still shows trouble after everything being tightened, you might have to leave it with them to fix. My only advice would be to determine before hand, how much it would cost for the check up - not including new parts. You wouldn't want to ask if they found the problem and them say either yes or no, but first you owe them $150 or something... So it woud be a good idea to sort that out before hand.
p.s. I once saw a PC which had been working for years, and then all of a sudden started having strange faults. It turns out, the graphics card had worked its way loose somehow... and wasn't fitted in the slot tightly anymore. Its strange because the PC was always still, in the same place, had never been bumped or moved. So if a lead popped off your motherboard or something, that could be the cause of your problem. I still think its most likely the PSU though. Pre built PC's (particularly Dell's) try to save money wherever they can. Most people measure how good a PC is, by its CPU, Memory, Hard Disk space etc.... So these manufacturers are sneaky and use ok components for those parts, but then cheap components for everything else. The result is PSU's (power supplies) dying after a year or two.
The plus side, is that a new PSU isn't that hard to fit (for a PC repair shop etc..). How expensive it will be, will depend on what the rest of the components are. I would hazard a guess, but I don't live in the US, so someone else would be better guessing on the price of that.
Good luck.