I have a desktop at home and it turns on for like 5 seconds and turn right back off. I leaning towards that the power supply is bad. When it turns on you can hear everything has turned of but then it just shuts right off. Nothing comes on the monitor but that because it does turn on long enough. Let me know if what i think could be it or if somthing else it bad on it.

open the case.
unplug =everything=
blow out the dust, dirt, & small animals
firmly reseat everything
try again.
(stuff needs reseated because as the pc warms then cools, the expansion / contraction pushes the cards / plugs away from where you want them.)

failing that, do you have a power supply to swap out? (use a known-good one; a new one may or may not be any good.)

How old is your computer?
And how big is your power supply?
Could be age, or could be that you don't have enough power, also how long has this problem occured for?

the computer is 4 years old. My cousin gave it to me to see if i could fix it. I dont have another power supply to see if it that. I have unplugged everything. One time when i unplugged the cd drive it stayed on but i didnt hook the monitor up so i didnt know if anything cam up. I just turned it on. But now when the cd drive is unhooked it just shuts right off. I think but im not sure when i took the memory out it stayed on but it the beep because it had no memory in it but im not sure if i did that or if it was something else.

the power supply is the one that came with the computer i believe it around 500 but i would have to check.