Drupal - Contact module, CAPTCHA. Feedback form with captcha
To learn how to create a contact form with CAPTCHA, watch the video linked in this article.
A contact form has long become an essential part of a company website. It’s used by clients and customers to get in touch with the site owner or company managers. In Drupal, this functionality is provided by the built-in Contact module. Using the Contact module and an additional CAPTCHA, we’ll add a spam-protected contact form to the site.
Let’s enable it. A new item should appear in the admin menu under Structure - Contact form.
Let’s add a contact category and name it Manager.
Now the contact form is available at the address: your_site_name/contact
Let’s add another contact for the site administrator and name it Administrator. Now the contact form will display a dropdown to choose the contact category.
After setting up the contact form, you need to configure CAPTCHA to protect it from spam. If the contact form is left unprotected, someone could write a script to automatically send messages. For that, we’ll need to install the CAPTCHA module, which adds CAPTCHA to forms. Download and install this module. To configure it, go to the admin menu under Configuration - CAPTCHA settings.
On this page, choose the CAPTCHA type you want to use for the form. You can also select CAPTCHA types for user registration forms and comment forms. Save the settings. Now the contact form will include a CAPTCHA for both registered and anonymous users. However, if you’re logged in as the admin user, you might not see the CAPTCHA. Let’s configure CAPTCHA so that it appears only for anonymous users. This is done through permissions. Go to the admin menu under People - Permissions.
The contact form is now configured. The only thing left is to add a menu link to the contact form. You can read how to add a menu item in one of the previous lessons.