You need to get a visa in order to enter the UK for the purpose of marriage. You will be granted a period of 2 years and can then apply for further leave to remain and eventually indefinite leave to remain.
http://www.ukvisas.gov.uk/servlet/Front?pagena me=OpenMarket/Xcelerate/ShowPage&c=Page&cid=11 06654124706
If you are already in the UK you need to get a Certificate of Approval before you marry, however it depends on what your status is here at the moment.
Only in exceptional circumstances will you be allowed to apply for apply for leave to remain for this purpose, the normal way is to get a visa before entering the country.