Unlike losing weight, when you gain muscle you can choose what part of your body you want to focus on. This can be problematic if you work one part of your body more than another. You want to have a balanced workout that hits all areas of your body equally.
Your first step should be to figure out your routine. There are two basic options. You can use the ACSM workout and go to the gym 2-3 times per week. This workout requires that you do 1-2 sets per muscle group and hit every muscle group during your workout.
The other option is to split up your workout into different groups of muscles each day. A popular split is: day 1: chest & triceps, day 2: back & biceps, day 3: shoulders, day 4: legs. With this type of workout, you should do 6-12 sets per muscle group (12-24 sets if you do two muscle groups in one day). Remember to leave at least 48 hours between working out the same muscle group.
If you have never worked out before, start with the ACSM workout. If you follow their guidelines you shouldn't be in the gym for more than an hour. The second workout could take between 60 and 90 minutes. The ACSM workout also only calls for you to workout 2-3 times per week where the second routine would require 3-4 times per week depending on how many days you have in your routine. You don't want to do too much too quickly as this could cause you to quit all together.
Once you have a routine, you need to pick the exercises you'll be doing. There are plenty to choose from but when you first start out you should try and use the machines rather than the free weights. Once you're comfortable on the machines, you can move to the free weights. Keep in mind that free weights (especially if your form is off) do not necessarily provide a better workout. A good routine will combine machine and free weight exercises.
If you chose the ACSM workout, you'll need to pick one exercise for each muscle group (quads, glutes, hamstrings, calves, chest, back, shoulders, biceps, triceps, abs). If you chose the split workout, you should do 2-3 sets per machine (or free weight).
With both the ACSM workout and the split routine, you need to workout the bigger muscles first. If you do the ACSM workout, start with legs and move on to upper body. If you do the split routine and pair back with biceps and chest with triceps, make sure you do your back and chest before your biceps and triceps.
The last thing you need to keep in mind is to change your workout. Overtime, your muscles become used to the workout you do and when this happens you need to change your exercises and the order that you do them in or you won't progress. You can also write down all the weights and repetitions you do in a workout log. It'll save you time when you do the same exercise during your next workout since you won't have to guess where you left off.
The Bottom Line
While eating is very important in gaining weight, sticking to your routine is crucial in gaining muscle. If you eat without exercising hard you may soon find yourself needing to lose weight.