Why is my iPhone acting like this, and how do I fix it?

I've had my iPhone 4s for about 2 years and today is the first day this has been happening. Its basically turning on and off by itself, and while I'm putting in my passcode the brightness gets low, and it erases what I type in so I have to put in my passcode fast. You know how when you want to turn your phone off completely, and you press the power button for about 10 seconds, and on the top of your screen it says "slide to power off" and on the bottom there's a button that says "cancel"? Yeah, well that has come up by itself many times. I have turned my phone completely off and turned it back on, and have rebooted two times, but this still happens. I don't know what to do. Has this ever happened to you? What should I do?

Look up iPhone hard reset

  • Why people like iPhones? I can't never get people who like iphones to give a good reason, why? Some say it easy, but a lot have no clue on how to use their own phones. Can someone explain something useful that great about iphone? Everything they think is special other phones have been doing for years.
  • Why is my iPhone Wi-Fi acting up? Okay so lately my Wi-Fi on my phone has been really annoying. Like I refresh a page or app and it like does the circle thing for a while and says error on the app. Itll be "refreshing" for a couple minutes and stop and its really annoying. But my Wi-Fi is fine on my computer and everything else. Please and thanks!
  • Why is my iPhone acting weird after updating it? When I'm using 3G and I search for something on google or try to open a link from my Facebook app, I get a message that says "Response Error. Technical description: 502 Bad Gateway - Response Error, a bad response was received from another proxy server or the destination origin server." What the hell does that mean?
  • Why is my iPhone 5 acting up? Well this morning my phone was great. No glitching, freezing or anything. But during school when we were able to have our iPod's out, My phone wouldn't turn on. So I tried rebooting (home and on button) still stayed off. But then it worked. But now it's not turning on at all. At first when I tried, my screen had a scratchy effect kindof like that weird Slender Man game when he pops up. I need help. Ideas? D