you can't get married while visiting the UK. In order to get married in the UK you, as a non-UK citizen or permanent resident, need to be in possession of either 1) a fiance visa, 2) a certificate of approval (only possible to get if already in the UK on another visa longer than six months), OR 3) a marriage-visit visa (for people who just want to visit the UK to get married but plan to settle in another country.) The registrar will not marry you if you don't have one of those three things.
If you want to get married to your girlfriend and stay in the UK, your best bet is coming over on a fiance visa (there are lots of threads on that here, or you can find out more at
http://www.ukvisas.gov.uk.) Your other option is getting married in the US or another country and then you'd need a spousal visa in order to go back to the UK to live.