Illegitimacy was not uncommon in earlier centuries. About 5% of all children born in England and Wales between 1837 and 1965 were illegitimate, which means they were born out of wedlock. It is no longer frowned upon like it was in the past, but finding that your ancestor was illegitimate may pose a problem when you conduct family tree research.
It was not uncommon for a child to take the surname of their mother's future husband, if she subsequently married, but it does not necessarily mean that this man was the child's father.
When illegitimate children married, they did not always state their father's name on a marriage certificate because they might not know it and also because the father might not have acknowledged their child. If the father was not stated on a marriage certificate, the person may have been illegitimate.
It is possible they could simply make up a name, giving this fictitious man the same surname as themselves which can be very confusing when researching family history. I have experience of this as my own relative, William Dunkley, stated Joseph Dunkley was his father when he married. Joseph was in fact his uncle.
After 1837, finding that no father is recorded on a birth certificate usually meant that the child was illegitimate. The mother's maiden name was stated in these circumstances.
This causes a problem in family history research, but sometimes the registrar or clergyman would insist that the baby was given the father's surname as a middle name. My ancestor William Baker Carrington was illegimate, subsequently changing his name to William Carrington Baker. If you find your ancestor has a surname as a middle name, they could have been illegitimate, so if you are unable to find their birth registration, it is worth checking the index under their middle name as well.
In earlier centuries, illegitimacy was considered sinful, and the clergyman could be most unfair to illegitimate children by writing the word 'bastard' after the entry in the baptism register.
The above image is produced with permission from Northamptonshire Archives
From 1576, Justices of the Peace could track down the father of a bastard child and issue a bond known as a Bastardy Bond. Bastardy Bonds were issued by the parish against the father of an illegitimate child, so that they could ask him to reimburse the parish for any possible expense of looking after the child. Bastardy Bonds can be found in quarter sessions records.
The Bastardy Examination was conducted before two Justices of the Peace and enquired into the circumstances surrounding how the woman became pregnant. A woman had to attend a bastardy examination, but these usually occurred after the birth of the child.
I have come across a great site which gives details of bastardy examinations, and also lists further reading on the subject should you wish to know more.