Syncing your contacts to an online address book requires you to have an active online account in the address database. From your phone's account settings, add your account detail configurations and select Sync.
Modern smartphone operating systems provide for easy setup of exchange sync configurations through the Settings windows. On an Android-based phone, Google is one of the best sync options for your contacts. To sync your contacts, you are required to have an active Google account; if you do not have one, setting one up is very straightforward. From your home screen or launcher, select the Settings icon and scroll down to Accounts. Choose Google, and provide your email and password in the text field. A list with what to sync should appear; select contacts and anything else you wish.
From an iPhone, iCloud is more optimized, but Google and others are also plausible options. Open your Settings menu, choose Mail, Contacts and Calendar, and select Account. You can pick any account of your choice, and a pop-up should appear. Fill in your account details and select Next with the Contacts option on and save.
The setup process on other phones is different, but typically it provides a graphical user interface to set up your account details.