Custom Drupal Contact Form
By Robert Safuto on Oct 28, 2007 in Tutorial
This video tutorial shows you how to create a secure, custom contact form using the Drupal content management platform. The following modules are used in creating this form. Akismet, Content Construction Kit, Form Store, MyCaptcha and Notify.
Donate $2
If you found this video to be helpful to you please consider donating the small amount of $2. Or if you need web hosting click here and you'll save $50 off monthly and up hosting plans with Dreamhost. Either way your support is greatly appreciated.









Lynae | Nov 18, 2007 | Reply
Hi Rob,
I’d like to thank you for taking the time to make these tutorials. As a Drupal novice I am finding them very helpful.
One thing I’m confused about, though, is that when you are creating the ‘contact_email’ field, you have field types that I don’t have–specifically the “E-mail” type. I thought perhaps I just needed to create a text field type and call it “E-mail” but then I noticed that after you created your field, your screen showed “E-mail link type: Mailto: Direct link”…so I scratched that idea.
That’s where you lost me.
I don’t know how to get the same field types you’re showing (like link,five star rating, email, datestamp, etc.) so that I can continue with the video to make a secure contact form? Is there a tutorial I should watch before this one that explains this?
Thanks!
Lynae | Nov 18, 2007 | Reply
Kindly disregard my question, I’ve found the answer–thanks.
Robert Safuto | Nov 18, 2007 | Reply
One of the confusing things about CCK is the fields. I think the answer you might have found was that many of the field choices in CCK are add ons themselves to the original module.
People can browse add-ons for the CCK module at http://drupal.org/project/Modules/category/88.
Lynae | Nov 20, 2007 | Reply
You’re exactly right–that is what I discovered by pure accident and in a round about way. I was looking through some more of your material and out of curiosity, I clicked on a trackback link (as I haven’t yet gotten around to fully investigating what these are and/or their purpose).
Long story short, I ended up taking a whirlwind tour through several Drupal related sites; got sidetracked reading about something else (CCK related most likely); clicked on a link and found myself on the exact Drupal download page for the Email Field add on. As soon as I saw it and the other add ons listed I had one of those wonderful ‘light bulb’ moments and am happy to report that, thanks to your most helpful tutorial, I now have a functioning secure contact form on the site I’m working on!
There is one teeny, tiny, little problem I’d like remedy…do you know if there’s a way to eliminate the default word “Submit” from the form’s title?
Thanks again!
Nicolas | Dec 4, 2007 | Reply
Hello Rob,
First off, I’d like to say that your tutorial is fantastic! It’s just what I needed. Having said that I have a small problem with the method, and I hope someone can help out. I have used this method for this site: http://www.forensic-centre.com/drupal/
The problem is that when you submit the contact form you return to the front page, and the user doesn’t know what is going on. Is it possible to have a message like ["Contact Form Submission Processed!
You have successfully processed the contact form with all the required values.
Your question, query or request will be attended to as soon as possible.
Thank you for contacting us!"] when you submit the form. Maybe once you submit it redirects you to a page with hat text, or it shows a system message on the front page with that information. Can anyone help me out? Thanks in advanced.
Robert Safuto | Dec 4, 2007 | Reply
Good question. I don’t know the answer as of yet. Will do a bit of research to see if there’s a way to redirect to a certain page or show a message when posting a node.
Robert Safuto | Dec 5, 2007 | Reply
I found a module that works on Drupal 5 and does exactly what you (and I) need.
What you can do is create a page that thanks the visitor for their submission. Then use the NodeGoTo module to direct the user to that page upon submission of your form.
http://drupal.org/project/NodeGoTo
Jon | Jan 10, 2008 | Reply
I like the tutorial but I can’t figure out how I can add the contact form to the site at the end so I can link to it from a link called “contact us”?
thanks
Jon
Robert Safuto | Jan 10, 2008 | Reply
What you should end up with is a page view that has a url of your choosing like “www.yoursite.com/contactform” for example. If you don’t know how to get there you should start with my CCK and Views Tutorial.
So once you have the view set up you link to that page by adding or editing a menu item. You can do that by going to ‘admin/build/menus’ or by clicking the administer link and choosing ‘Menus’ from the ‘Site Building’ section.
Once your in the menu section you click ‘Add item’ to add the link to the contact form to one of your menus.
I hope that helps.
Nicolas | Jan 17, 2008 | Reply
Now I’m using NodeGoTo to redirect the user to a thank you page. Thanks very much for the awesome tutorial and feedback on the comments. I have one more request that would make this tutorial even better, for users to get the entire message from the contact form in their notification mail instead of just the title and the URL. This would make a much more robust contact form system, and one that I would use for sure in all of my drupal sites. Thanks Robert!
raf | Jan 30, 2008 | Reply
encore une fois : great.
bravo.
I am going to try NodeGoTo.
I’m too poor to make you a donation, but if you need some organic coffee from here, tell me.
here ( our place of work) :
http://buzenval.110mb.com/tofs_polo/
ciao
r
Ed | Feb 13, 2008 | Reply
I’m also trying to figure out how to add the contact form to the site. I also watched the “CCK and Views” tutorial.
I’ve made the “contact form” content type and a page view. The problem is that the page view shows the results of the form submission and not the form itself. What am I doing wrong?
Robert Safuto | Feb 13, 2008 | Reply
When you create a contact form the form will exist as a new content type. Using the ‘blog’ content type as an example, if you are using clean urls you should see the blog entry form by going to the link “node/add/blog”.
Likewise, if you create a contact form with a content type of ‘contact’, you should see the form at “node/add/contact”. Does that make sense?
Dries | Feb 22, 2008 | Reply
So how exactely do you make a view that provides the form that users can fill in? You can ofcourse provide a link, but what if you want it inside a view? I can only filter by node in Views, where I derive from your comment that one should be able to filter by content-type. What am I doing wrong I wonder?
regards,
Dries
Robert Safuto | Feb 22, 2008 | Reply
If you haven’t done so, please watch the CCK and Views tutorial. That will help a great deal.
When you create a new content type you are directing people to the node creation form for that content type. So you don’t have to create a view in order to get people to the contact form.
Once you have created the new content type that will act as the submission form, there are two things you’ll want to do. First, make sure you give anonymous visitors access to that content type. Second, you’ll want to create a menu item that links to the node creation form.
Paul Izzo | Mar 7, 2008 | Reply
Rob,
My domain name has not yet been propagated.
I am trying to work with your custom contact form tutorial, but can’t find the administrative page where you clicked on Modules.
Can you lend any help?
Thanks,
Paul
Robert Safuto | Mar 8, 2008 | Reply
That is available via the admin screen. If you have clean urls turned on you should see it in the ’site building’ section at yourdomain.com/admin. Without clean urls you can find the admin area by typing in http://yourdomain.com/?q=admin.
The direct link to the modules page is http://yourdomain.com/?q=admin/build/modules.
Justin | May 23, 2008 | Reply
Hi Rob,
Thanks very much for this tutorial. I found it very helpful and just sent you a paypal donation. I have one question:
What’s the best way to theme form submission pages? Usually I would just create a file such as page-node-566.tpl.php to theme a page whose nid is 566. I can’t seem to figure out if my form submission pages have nids. If so, I assume I can theme them as I would any other node.
I’ve read the suggestions on getting the current’ node’s nid here http://drupal.org/node/160921 but I’m not sure how/where to implement the suggested php code, or if it would even work in this instance. I’m using D5.6.
So, what’s the best way to figure out the nid of a form submission page, such as http://www.mysite.com/node/add/comments-form? And if you can get the nid, can these pages be themed just like any other nodes?
Thanks very much for any help.
Robert Safuto | May 23, 2008 | Reply
Thank you Justin. You got me on the form theming issue. Definitely not an area where I’m too strong. There’s some info on Drupal.org about How To Theme A CCK Input Form at http://drupal.org/node/101092. It looks to me like that might be of assistance to you.
Sophia Browne | May 27, 2008 | Reply
Hi,
When I set the access control to create contact form for anonymous users, the “Create Content” link shows up on the menu.
How can I prevent that without disabling it for administrators.
Note, I am a total noob.
Robert Safuto | May 27, 2008 | Reply
Sophia: You can control the display of the menu item by going to the menu section under the administration panel and disabling the particular link that you don’t want people to see. Admins will still be able to get to the create content link by going to /admin on your site.
Alternatively, you can configure the navigation block (in admin/build/block) to only be visible by the admin. In the block configuration window you look for “Show block for specific roles:” and select the roles that you want to see the block.
When I build sites I usually create a special menu block for site users and only allow admins to see the standard navigation block.
Sophia Browne | May 28, 2008 | Reply
Thanks a lot for your prompt help!
Apeee | Jul 22, 2008 | Reply
Is it possible to send the submitted form to specified email address as in drupal core contact.module where user can decide to which department to submit the form if choices are given.
And can user get a confirmation email after form submission similarly as in drupal core contact.module.
All the way nice tutorial!
Scott | Jul 23, 2008 | Reply
Does the video get cut off for anyone else? I think it ends at 29 min but look like it is supposed to be about 34…
Robert Safuto | Jul 23, 2008 | Reply
Something may have gotten cut off during encoding at Blip.tv. Try downloading the Quicktime version. I’ll put it on my to do list to re-upload.
Robert Safuto | Jul 23, 2008 | Reply
Apeee: Two things that will help you achieve what you’re looking for.
1. Try the Node Go To module if you’re on Drupal 5. This module will re-direct the user to a specified page upon successful submission of the form. http://drupal.org/project/nodegoto
2. You can send the form results to an email address. Since the form is a node you need to use a module that provides email notifications when nodes are published. Try the new subscriptions module, which used to be called Notify. http://drupal.org/project/subscriptions
Rob
Louise Goldstein | Aug 4, 2008 | Reply
Fantastic tutorial, I implemented this on one of my sites but then wanted to be notified by email when someone enquired I used the workflow-ng module http://drupal.org/project/workflow_ng it did just what I needed hope it helps others
Robert Safuto | Aug 4, 2008 | Reply
That’s great Louise. I’m glad that it helped. Thanks for sharing the link too.
Mike Scearce | Aug 14, 2008 | Reply
I started with a 6.2 installation back in June, and being a noob with Drupal, have absolutely no clue as to the differences between 5.x and 6.x implementations. Lovely video, but many of the modules are not 6.x ready.
How does one achieve a form such as this in 6.x?
Robert Safuto | Aug 17, 2008 | Reply
Mike,
Drupal 6 has a number of enhancements that makes managing the site easier. I recommend that you check out my Drupal 6 overview at http://learnbythedrop.com/drop/4 if you haven’t done so already.
The process is a bit different in Drupal 6. You don’t need the Notify module to send you an email because D6 has something called Actions and Triggers that can inform you when a form is submitted.
Rob