The concept is not too hard. Have your script generate a random word then have the script create an image out of the word and enter the word into an auth word list.
Print the image to the screen, have the user enter it into a form, and check the users entry against the auth word list.
Check hotscripts.com for a ready made script or study the different functions needed for this at php.net (or which ever language you use).