To turn OFF iPhone you can use program Tiny Umbrella. To turn iPhone back ON you use Tiny Umbrella again. All very simple actually.
Download Tiny Umbrella to computer, open iTunes and Tiny Umbrella, connect iPhone to computer with USB cable. Select iPhone name in Tiny Umbrella, click "Enter Recovery" button in Tiny Umbrella. When you see the iTunes Logo on iPhone screen it is in Recovery Mode. Now disconnect iPhone from USB cable. 30 seconds later iPhone will automatically turn OFF.
When you want to turn iPhone back ON, push Power button, or in your case if Power button fails, just connect iPhone to USB cable and computer or Wall Charger. iPhone will power right up, but will still be in Recovery Mode. Connect to Tiny Umbrella on computer, select iPhone name, click "Exit Recovery" button. Done. Actually very easy once you give it a try.
This is a little late but maybe will help someone else since I just had to do it.
If the top button is not working and you need to power off the phone, Go to:
Settings --> General --> Accessibility --> AssistiveTouch
Set this setting to On. This will place a transparent black square with a white dot in the center on your screen. Tap the dot and and a menu will pop up, one option on the menu is Device and has a simple image of the iphone on it. Tap Device, the a second menu will pop up, this menu will have a Lock Screen image on it. Press and hold this icon and the screen will transition to the normal power off screen. From here power off like normal.
Now once you get it turned off, if you need to power it back on you just have to plug the device up a charger. Once it's plugged in the device will power back on.
Thank you so much for the Tiny Umbrella idea. It worked for me and saved me a lot of time and frustration.
I have an iPhone 4 whose power/lock button doesn't work. Recently, my phone froze, and all I could see was a black screen. Also, the assistive touch button was visible, and it worked, but pressing any of the assistive touch buttons didn't do anything. I'm guessing some major background process died.
Ultimately, I was left with a frozen phone that was on, where assistive touch failed, and the power/lock button didn't work. The only way that could work for me was to turn the phone off and then reboot it. Thankfully, I read your solution about Tiny Umbrella, and it worked perfectly.
If I hadn't used Tiny Umbrella, I would've had to wait for the battery to drain completely so I could plug it into a charger to turn it on again.