Thanks for the question, and welcome to Apple Support Communities.
I understand that you are having issues connecting to Wi-Fi networks with your iPhone 5. The following resource may lead to a resolution:
Unable to automatically connect to Wi-Fi
- Some wireless routers are preconfigured with a common SSID (network name) such as "wireless" or "default."
- If your desired Wi-Fi network has a common SSID, try changing the SSID to something unique2.
- If your desired Wi-Fi network has a unique SSID, reset network settings by tapping Settings > General > Reset > Reset Network Settings.
- Note: This will reset all network settings including: previously connected Wi-Fi networks and passwords, recently used Bluetooth accessories, VPN and APN settings.