If you're out at a coffee shop, hotel, or airport and can't get a data connection on your phone, then you'll need to connect to Wi-Fi.
First and most importantly, you should only join a Wi-Fi network that's reasonably secure. Head to the Settings app, then toggle Wi-Fi on, and a list of available networks should pop up. You'll see a padlock next to networks that require a password. That doesn't guarantee that the network is safe, because you don't know who else is on the network. But you can at least verify with staff that you're connecting to the property's official network and not some phisher's cleverly named knockoff. Select your preferred network and enter the password, then tap Join. Once your phone's connected, you'll see a checkmark next to the network and a Wi-Fi antenna symbol in the upper-left side of your display.
When you're done browsing, it's good practice to log out of any services you were using. Then, to ensure that you won't automatically reconnect to the network the next time you're near it, tap the network name, then Forget This Network.
You can follow the same process if you're trying to connect to Wi-Fi in a friend's or family member's home. Ask your host for their network name and passcode. Find and select your host's network name under Settings, then Wi-Fi, enter the password when prompted, and tap Join. Again, when you're done browsing, log out of any services you used and tap Forget This Network.