1) Proper User Input Validation
To protect your web site you or the people you work with have to check properly data that comes from user's input.
e.g. there a lot of people that will make you a contact form as quickly as possible for about 2 mins (low quality code), the data may not validated correctly and some people may user your contact form to send spam by injecting "To:
victim@domain.com\r\n".....
2) Use CAPTCHA
CAPTCHA in your forms in order to stop bots and automated programs
3) Protect your host
If you're on a shared hosting the hosting company takes care of the security of the servers, on the other hand if you have a dedicated server you have to hire a very good system administrator to keep your server up-to-date and apply necessary patches where needed.