Yes, you can take trains from Florence to the Cinque Terre; it will require at least one change somewhere along the line, usually in La Spezia.
The easiest thing to do is to get onto the Trenitalia website:
http://www.trenitalia.com/tcom-en
Enter your point of departure; Firenze S. M Novella (Santa Maria Novella) is the main station in Florence.
Enter your point of arrival: I might use Monterosso as it's the furthest north of the 5 villages. You can work your way back south again by train, and then back to Florence. You may, however, choose any village you wish.
Enter your travel date or random day and desired time of departure from Florence. Click "search"
All of your options will come up. Do the same in reverse for trains going back, or simply click the round-trip button when figuring your trip.
You do not need to purchase these tickets in advance as they are not all that expensive and you'll want the flexibility to choose the nicest day to go anyway. Just use the system to get an idea of what is available and then buy tickets the day of your journey. Do note that it's 2.5 to 3 hours one-way.