The way it works depends on the phone. First of all, your phone has to support the modem function and second, you need drivers to be installed on your pc to make it happen. You also need some kind of service plan to the internet, i.e. the "number" your phone dials. With tmobile, you can dial to GPRS but GPRS requires the tzones subscription, which has different plan levels (they block ports for certain things). Alternatively, you can use CSD which is limited to a maximum of 9600bps (slow but good 'nuff for text emails, chats). CSD requires a 'dial up number' for which there are free services out there specifically for cell phone use. GPRS does NOT use up voice minutes on tmobile; CSD DOES use voice minutes.
So essentially, the magic lies in your phone's ability to even be used as a modem and if there are any drivers to your pc for it. Like I said, not all phones support such functions, paritcularly cheaper ones. Oh, and you need some kind of connectivity to the phone and pc, such as a cable or , preferably, bluetooth.