My computer restart again and again

Friends when i insert windows xp CD and press f12 to install OS but when i insert windows 7 or Windows 8 CD and press F12 to install my OS my computer restart again and again.
My computer restart when I press key when windows show press any key to boot.I hope that I will get solution from this forum.....