In reply to goldmember:
so do i need to take the lid off?
You might as well as it's easy to do and by doing so you can see inside the machine. The fault might well be with the Console PCB - loose wire, etc. It also gives extra light if you need to delve deeper into the machine at a later stage.
Depending on the model, the display will give you a fault code. The LCD type will display an Fxx code and the LED only type will flash their LED's in a certain sequence. I'm pretty sure the fault codes can be found on the Internet for the Model No of the machine. In this case, it will probably say that the Door Lock is knackered...
If the Console PCB looks OK, have a look at the Main PCB around the back for obvious signs of damage around the connections - Be careful, even with the machine turned off, there is a risk of shock due to capacitors being used. Leave it for at least 30 minutes before putting your hands inside.
If there's no obvious damage there, I suppose changing the door lock is a cheap repair and if it works, all well and good. Just hope there isn't an underlying problem causing it...
I'm not a Washing Machine Repair Man, so take anything I say at your own peril!