I had success with an iPhone 5 I just got on T-Mobile that was having the same issue. I am not sure if this will work on the iPhone 4 but it is worth a try I guess. I selected my home wifi network, entered the password, after I put the phone to sleep the wifi password would need to be re-entered. What I did to fix the issue was to go into settings > wifi > other > then manually enter your wifi name and password. Under security choose WPA.