How to Create a Contact Form with Expression Web

Chapter 9: Create an Email Web Form for Visitors' Feedback

How to Create a Contact Form with Expression Web

by Christopher Heng,

Many websites provide a way for their visitors to contact their webmasters. For example, some people put their email addresses on their sites. Others put up a web form, which visitors can use leave feedback. In this final chapter of the Expression Web tutorial, you will be creating such a form.

This chapter assumes that you know the things covered in the earlier chapters. If this is not true, please start at the beginning with How to Create Your Own Website.

Goal of This Chapter

By the end of this chapter, you will have a working contact form. In addition, if you have been following this tutorial from chapter 1, you will also have completed everything, and have a fully-functional multiple-page website "live" on the Internet. With this chapter, you will have acquired most of the commonly-used knowledge needed to design and maintain a site using Expression Web, and will be able to create more as and when you wish.

You Can't Just Design a Web Form and Expect It to Work

Web forms are tricky beasts for newcomers. Very often, a new webmaster will create a form using his/her favourite ("favorite" in US English) web editor, complete with bells and whistles, only to find that the form does absolutely nothing but look pretty.

A form is only one part of a complex machine. An analogy may serve to explain its place in the bigger scheme of things. Let's say that someone decides to create an intelligent computer that can chat with them on lofty matters. They get an empty cardboard box, paint it black, attach pretty buttons on the surface with different labels, such as "Discuss Philosophy", "Poetry", and "The Meaning of Life". But when they press a button, any button, they are greeted with silence. Creating the user interface (the sleek black exterior and buttons with weighty topics) is well and good, but without an actual engine working its magic beneath the surface, one can click the buttons till they are blue and not get the desired results.

In the same way, a web form is just the user-facing component of a bigger whole. The engine driving the form is a computer program that is custom-built to process the stuff coming out of the form. Designing a form without having a program to handle its output is like putting buttons on a empty cardboard box and expecting those buttons to actually do something.

But don't panic. For the contact form that you'll be adding to your site, you don't actually have to write your own computer program, nor is programming knowledge necessary. You will be using the Feedback Form Wizard to do the hard work for you.

Components of the Contact Form System

Before you continue with this article, please go to the Feedback Form Demo and try it out. This will give you an idea of how your contact form system will work. Please do this even if you have a lot of experience using web forms. The demo form uses the exact same engine that yours will use, since it was created using the Feedback Form Wizard. And don't worry about spamming me with that form; email sent through it is automatically deleted, so feel free to test it to your heart's content. Do it now, before continuing with the next paragraph.

From that brief experiment with the form, you will probably notice that the contact form system comprises 3 user-visible parts. In actual fact, there are many more, but you will only directly deal with the following 4 components.

  1. The Contact Form itself

    The web form itself is of course the most obvious part of the system. The Feedback Form Wizard will create this for you, and all you need to do is to plug it into your website. Its appearance (eg, the size of the fields, fonts used, colour, etc) can be customized from within Expression Web.

  2. The Thank You page

    This is the page your visitors will see after they successfully submit a message. You will be creating this yourself in Expression Web.

  3. The Error page

    If your visitors fail to enter important information into the form, such as their email address, this page will be displayed when they try to send the message. (You can see this page in the demo by simply clicking the "Send Feedback" button without entering anything into the form.)

    Like the "Thank You" page, you will create this page in Expression Web.

  4. The Feedback Form Script

    The Feedback Form Script is the behind-the-scenes "brains" of the form. It is actually a computer program that processes the stuff entered by your visitors and transforms it into an email message. (A "script" in this context means a computer program.) It then asks the other programs on your web host's computer to send the email.

    Yes, you read that right. The script doesn't actually send the email. It doesn't need to. There are programs on your web host's computer specially designed to handle email. Many programs on your web host's computer have specific functions, and they all work together to do complex tasks. It's like the division of labour you find in human organisations.

    After handing off the message to the other programs on the system, the script then tells your visitor's web browser to go to the "Thank You" page.

System Requirements

For the contact form to work, the following are required.

  1. Your web host must allow you to run PHP scripts

    The script generated by the Wizard is written in a computer language called PHP. (See What is PHP? if you want to know more.) For it to work, your website must be placed on a web server (ie, your web host's computer) that has PHP installed.

  2. Your PHP scripts must be allowed to send email

    Not only must your web server have PHP installed, it must be configured so that PHP scripts are allowed to send email. This is generally the case for commercial web hosts, but is not necessarily true for free ones. Many free web hosts that permit PHP disable its email-sending facility, presumably to prevent people from using their system to spam others. As such, if your site is on such a host, your form will probably not work correctly.

    Note that when I say "free web host", I include any situation where you didn't have to pay to have your website hosted. This include the free web hosting that sometimes comes with your Internet broadband connection and the "starter websites" that you get for free when you buy a domain name from some registrars.

    That said, the feedback form script has been successfully used by thousands of sites on many commercial web hosts.

How to Create a Contact Form

Please follow the instructions below meticulously. Do not skip any step. In addition, I recommend that you do not work from memory, even if this is the second or third time you're doing this. Keep this article open in a window (or tab) of your web browser while you work, perhaps even highlighting the step you're following (just drag your mouse over the relevant sentence to highlight it) so that you remember where you are. It's easy to lose your place in the article because you will be switching back and forth between windows repeatedly.

  1. Go to the Contact (or Feedback) Form Wizard.

  2. Read the information on that page, and select the "Create a PHP Feedback Form (Requires PHP 5.2 or above)" option by clicking the radio button. (Actually, that button should already be selected by default, but click it again if you're not sure.)

  3. Click the "Go to Step 2" button.

  4. You will arrive at Step 2 of the Wizard. Enter the following.

    • Email Address

      Enter the email address at which you want to receive your visitors' comments. For example, enter "" (without the quotation marks) if that is your email address.

    • URL of Feedback Form

      Enter "" (without the quotation marks) into this field, replacing "" with the address of your website. Be sure to use the filename "feedback.html" since you have already used it in chapters 6 (for your navigation menu) and 7 (site map) to link to this form. If you change the name now, all your links will be broken.

      Even if you have not followed my tutorial from chapter 1, it's easiest to just use "feedback.html" as the filename, since I will assume that you have used that name in the rest of this chapter. If you use a different name, you will have to make sure that all the rest of the addresses mentioned here match up, or your form will not work.

      Note that the use of "feedback.html" as the filename does not force you to call your form "Feedback Form". You can call it anything you like, eg, "Contact Form", "Contact Us", "Support", "Feedback", "Help", "Comments", "Drop a Note" or whatever. It's just a filename; it has nothing to do with what you call your form, or how you describe it to your visitors. That is, nothing stops you from naming the file "feedback.html" and calling it a "Support Form" or "Contact Form". As such, I strongly recommend that you just use "feedback.html" for the filename. The procedure in this chapter is already complicated enough without your having to mentally juggle a name that does not match the tutorial's instructions.

      If you choose to ignore my suggestions and change the filename anyway, please remember the recommendations given in How to Create Good Filenames for Your Web Pages and not to use capital letters or spaces.

    • URL of "Thank You" Page

      Enter "" into this field, without the quotation marks and after replacing "" with your site's actual web address. Once again, the same stuff about changing filenames that I mentioned above applies.

    • URL of Error Page

      Enter "" into this field. As usual, don't include the quotation marks, and use your actual web address in place of my "" placeholder. And again, remember what I said above about changing filenames.

  5. Scroll down and read the "Terms of Use: Licence Agreement (Required)" section. If you agree to the conditions, indicate it in the form and click the "Generate script" button.

  6. The Wizard will then create a script and form for your site using the information you supplied. Do NOT close the page that is displayed. Leave it open as you work on the next few steps.

How to Save the Contact Form Script Without Introducing Problems

  1. If you have any file open in Expression Web, close it with "File | Close" from the menu. That is, for every file that is open, click the "File" menu followed by the "Close" item in the drop down menu that appears.

  2. Click "File | New | PHP" from the menu.

  3. A seemingly blank page will appear. Alas, the page isn't really blank, so we will have to fix it.

    Click the "Code" tab at the bottom of the blank page to switch to Expression Web's code view.

  4. You will see the default HTML code that Expression Web inserted into the page. Click "Edit | Select All" from the menu to highlight everything.

  5. Hit the Delete key on your keyboard. This will remove the text.

  6. Switch back to your browser. Click your mouse once in the box located in the "Feedback Form Script" section. This will automatically highlight everything there.

  7. Click your right mouse button while the pointer is hovering over the highlighted area. Click "Copy" in the menu that pops up.

  8. Switch back to Expression Web and click "Edit | Paste" from the menu.

    A whole bunch of seemingly gibberish text will appear on the screen. Do NOT change anything, not even to add blank lines. Although some of the words look like English words, the entire thing is a computer program. Modifying anything may lead to the script failing to work correctly later.

    For those of you concerned that your email address is embedded in this script, and that your visitors might see it, don't worry. As long as your site is on a system with PHP, nothing on this page will be visible at all. In fact, at no time will the script be even sent to your visitors' browsers. This is the case even if your visitors try to access it directly. They'll just end up being supplied your feedback form instead. If you don't believe me, you can test it yourself later when you've successfully installed everything. Instructions for this (as well as explanations why this is the case) are provided in the section on testing below.

  9. Click the "Design" tab at the bottom of the window. You should again see a blank page. Do NOT type anything here. Although it looks blank, it's still the feedback form script you just saw. Anything you type here will break the script.

  10. Click "File | Save As..." from the menu.

  11. Type "feedback.php" (without the quotation marks) into the "Save As" dialog box that appears.

  12. Click the "Save" button.

  13. Immediately click "File | Close" from the menu to close the file before you accidentally alter something.

How to Insert the Contact Form

The contact form proper is simply the user interface that your visitors will interact with. It should be placed on a normal web page, like those that you have created in the previous chapters. As such, the initial few steps will be very familiar to you, since you have repeatedly used them to create the other pages of your site in the last few chapters.

  1. Click "File | New | Create from Dynamic Web Template..." in Expression Web.

  2. Click "index.dwt" or whatever your template file is called.

  3. Click the "Open" button.

  4. Click the "Close" button in the "(1 of 1) files updated" dialog box that appears.

  5. Click "File | Properties" to bring up the Page Properties dialog box.

  6. Change the Title field to whatever you want to call the page. For example, if you want to call the page "Contact Form", type the latter (without the quotation marks, of course) into the Title field.

  7. Click the "OK" button.

  8. Remove the content in the right column and put "Contact Form" (or "Feedback Form" or "Support" or whatever you like) at the top of the page as a heading.

  9. Switch to your browser and scroll down the page to the section with the heading "HTML Code".

  10. Click once in the box in that section. As before, the contents of the box should be immediately highlighted.

  11. Click your right mouse button and select "Copy" from the menu that appears.

  12. Switch back to Expression Web. Put the text cursor at the spot on the page where you want the form to appear, by clicking your mouse pointer there.

  13. Click the "Code" tab under your page to switch to Expression Web's code view.

  14. Look for your text cursor. (Don't click on the page itself to scroll up or down, or you may accidentally relocate the text cursor. Instead, click the scroll bars on the right side and at the bottom to move the page up and down.)

    If your cursor was previously in an empty paragraph, the text cursor will probably be somewhere in the midst of "<p>&nbsp;</p>" (probably after the "<p>" and before "&nbsp;</p>", and the whole line will be underneath your heading (eg, "<h1>Contact Form</h1>"). However, since your page design is different from mine, don't worry too much if it isn't exactly as I describe here. I'm just stating the most probable scenario, to help you spot that elusive cursor.

  15. If your text cursor is within "<p>&nbsp;</p>", move it to the end of the line, so that it is just after the "</p>" on that line. Otherwise, go to the next step.

  16. Click "Edit | Paste" from the menu. The code you copied earlier from your browser should appear.

  17. Click the "Design" tab at the bottom of the page to return to the Design view.

  18. You should see the form on your page.

    If you find that the fields are too low on the page, with too much space between your title and the form, it means that there is an empty paragraph in-between. Click the empty space above the form fields to put your cursor in the empty paragraph and hit the Backspace key on your keyboard to get rid of it.

How to Customize the Appearance of the Form

If you like, you can customize the appearance of the form so that it fits in with the existing design of your web page. This is OPTIONAL. You don't have to do this if the form already looks fine on the page. The code created by the Feedback Form Wizard is designed to work out-of-the-box without needing any further tinkering. If you don't want to change anything, just skip to the next section.

The form obeys the same CSS rules as the rest of your web page. As such, you can use the techniques taught earlier to change the font, text size, and colours. I will not repeat those steps here, since you can easily return to the earlier chapters if you've forgotten how to do them. Instead I will focus on things you haven't learnt yet, like how to adjust the widths of the various fields in your form and how to change the words appearing on the button at the bottom of the form.

Another thing that you should know is that the widths and heights of the form fields are merely visual gimmicks. They do not affect how much information your visitors can enter. Even if you are parsimonious with space, and create extremely narrow fields, your visitors can still type entire novels into the name, email and comments fields. The web browser will automatically scroll to allow them to insert more text. Nevertheless, it's still useful to know how to adjust the field widths so that you can make the form blend aesthetically with the rest of your page.

How to Save the Feedback Form Correctly

When you are done tinkering with the form's appearance, click "File | Save As..." from the menu. In the "Save As" dialog box that appears, type "feedback.html" (without the quotation marks) into the "File name" field and click the "Save" button.

Now click "File | Close" from the menu.

(Optional) If you wish, you may switch back to your web browser and close the tab containing the Feedback Form Wizard's results page. At this point, you have finished integrating the Wizard's output into your site, so you don't need it any more. Your job is still not done, though. You still need to create the "Thank You" and "Error" pages. This will be done next.

How to Create the Thank You and Error Pages

As you have probably already realised, from experimenting with the feedback form demo earlier, the "Thank You" and "Error" pages are just straightforward web pages, much like your home page, site map and "About" page.

The "Thank You" page is displayed after your visitors click the "Send Feedback" button. Its main purpose is to reassure your visitors that their message has indeed been sent. Otherwise they'll think that nothing has happened and click the button again, with the end result that you'll get multiple copies of the same message. Most webmasters also take this opportunity to thank their visitors for their comments.

Create the page the usual way based on your site's template. Remember to replace the Title field in "File | Properties" with something like "Message Sent" or "Thank You" or the like. Then in the main visible portion of your web page, put a message like the following:

Message Sent

Your message has been sent to the webmaster. Thank you for your comments.

Actually, you can say whatever you want. The above is just to give you an idea of what to write. There are no rules as to what you must say.

Save the page with a filename of "thankyou.html" (without the quotation marks). Do not accept the default name that Expression Web suggests for that file. Like all the filenames mentioned in this chapter, it must match exactly what you supplied to the Feedback Form Wizard, without even any difference in capitalisation (case). Otherwise your visitors will receive an unfriendly "404 File Not Found" error when they click the "Send Feedback" button.

Once you've finished with the "Thank You" page, create the "Error" page from your site's template. This page is displayed when your visitors click the "Send Feedback" button without entering anything into one or more of the form fields. For example, if they leave the "Email address" field blank, they will arrive here instead of the "Thank You" page.

As such, your Error page should have a message telling your visitors to return to the form to complete all the fields before clicking the "Send Feedback" button. For example, you can say something like the following:

Error Sending Message

Please complete all the fields in the form before clicking the "Send Feedback" button. Click the "Back" button in your browser to return to the form to fix the error.

As before, remember to change the Title field in "File | Properties" to something like "Error" or "Error Sending Message". Save the file as "error.html" (without the quotation marks).

Publishing the Feedback Form, Script, and Support Pages

  1. Save and close all the files in Expression Web.

  2. Although you can click "Site | Publish All Files to [your web host name]" like you did in chapter 8, it may be faster to use "Site | Publish Changed Files to [your web host name]" instead. The first option forces Expression Web to upload all the files, both old and new, to your web host. The second causes it to check if the file already exists on your site, and only upload them if it doesn't.

    In most cases, since you have already done the initial upload of your files, you can probably get away with using "Site | Publish Changed Files [etc]". If you have a lot of files, this may save you time. However, if you suspect that Expression Web thinks that your web server's copy is the same as what you have on your disk, but you know it isn't, you can always force it to re-upload everything with "Site | Publish All Files".

    For now, just click "Site | Publish Changed Files to [your web host name]" from the menu.

    If both "Publish All Files" and "Publish Changed Files" are disabled (greyed out), it probably means that you did not set up Expression Web's site settings in chapter 8. Return to chapter 8 and get that sorted out first.

  3. Note that using this shortcut procedure, where you directly invoke "Publish All Files" or "Publish Changed Files" without first using "Site | Publishing" means that you won't get to see the list of files on your web server on the right hand side, the way you did in chapter 8.

    For the purpose of this chapter, since publishing a feedback form script and its supporting files is often tricky for newcomers, we really do want to make sure that all the files have been transferred correctly.

    As such, invoke "Site | Publishing" now, and click "Connect to the current publishing destination" link.

  4. Look in the right column and make sure you see the following files:

    • error.html
    • feedback.html
    • feedback.php
    • thankyou.html

    You should also see your other website files, like "index.html", "sitemap.html", "style.css" and "tswnavbar.css" in that same directory.

    If one or more of the above files are not present, you have made a mistake somewhere. Your contact form will not work correctly in such a state. Check your left column to see if you have actually saved the files in the proper location on your computer. If so, publish using "Site | Publish All Files [etc]" this time. On the other hand, if you do not see one or more of those files in either the left or right column of the Site View's Publishing tab, go back and follow my procedure above to create them.

    Note that you can leave this "Publishing" tab and return to your normal Site View panel by clicking the "Folders" tab at the bottom of the window (see picture).

    Tabs at the bottom of the Site View panel

How to Test the Contact Form

Since a feedback form is more than just a normal web page, there are many additional things you need to test before you can be sure it works as it should.

  1. Check that your navigation menu button links correctly to your form

    Go to the home page of your website. Click the "Contact" button (or "Feedback" or "Support" or whatever you called it) in your navigation menu . You should arrive at the form page. If you get an error message saying 404 File Not Found (or words to that effect), it means that you gave your contact form a different name from that used in your navigation menu button. Either fix the link in your navigation menu so that it points to the actual file you created (see chapter 6 for this), or redo this chapter and give your feedback form page the same filename you used in the menu.

  2. Check that your site map links correctly to your form

    If you have put a link to your contact form in your Site Map, go to the latter and click that link. You should end up at the form again. If you don't, you have a mismatch between URL you used in the Site Map and the one you actually used when you created the file. Fix it so that they both refer to the same address. And make sure that it matches the one you gave to the Wizard too.

  3. Check that you named the Error page correctly

    You are now ready to test the contact form. Click the "Send Feedback" button. Yes, I know you haven't entered anything into any of the fields. That's the whole point.

    Since all the required fields on the page were empty, you should end up at the Error page you created earlier. If so, all is fine. That is the way the form is supposed to work. Go to the next test.

    If you get a File Not Found error, it means that the URL you gave to the Feedback Form Wizard did not match the URL of your Error page. This may mean that you gave your Error page a different filename from that which you specified to the Wizard. Or you may have made a typographical error when you typed the URL of your Error page into the Wizard. Unfortunately, this error probably means that you have to redo this chapter again.

  4. Check that you named the Thank You page correctly

    Return to the contact form. Now complete all the fields there and click the "Send Feedback" button.

    You should end up at the "Thank You" page. If so, go to the next test.

    If you get a File Not Found error, it means you have a URL mismatch. The address you furnished the Wizard did not match the actual address of your Thank You page. Redo this chapter to fix the error. This time, check carefully that the URLs you type into the Wizard are correctly entered with no typos. (Really check, letter for letter.) In addition, use the filenames exactly as I suggested in this chapter; don't even vary the names by putting spaces or capital letters in the names. Those are the causes of many problems with URLs not matching.

  5. Check that you actually received the mail you sent

    Just because the Thank You page is shown does not mean that your email will arrive safely. As mentioned earlier, the Thank You page merely indicates that the script has handed the message to the specialised email programs running on your web host's computer. It doesn't mean that those programs have delivered your message or anything like that. In fact, you will even get the Thank You page if you made a typing error in your email address and your message goes nowhere because nobody can deliver mail to a non-existent address.

    Different web hosts also deliver mail sent from web forms at different rates. And the speed at which it appears in your account depends on whether the message is sent to a mailbox on the same web hosting account as your website, or to an external email service like Gmail. It's generally faster to deliver to a mailbox on your web host.

    If you do not get your test message after waiting at least a few hours, see the checklist of things to do when you don't get your email. You may also want to try the obvious step of making sure that you entered your email address correctly into the Wizard.

  6. For the suspicious: how to verify that visitors cannot see your email address from the script code

    Remember that I said earlier that the email address that you saw in the script will not be displayed in your visitors' web browsers even if they specifically put its URL in the address bar? Well, if you didn't believe me then, now is your chance to verify that claim. Actually, even if you believe my statement, please try the following experiment anyway, for your own peace of mind. Don't worry, you won't break anything.

    If your contact form is at "", the PHP script that you uploaded should be at "". That is, take the URL of your contact form, and change the part at the end that says ".html" to ".php". Type that new address into a tab (or window) in your browser's address bar and hit the ENTER key.

    You should be magically transported to your contact form. That is, you will not see the program code. In fact, the script code was never at any moment transmitted to your browser.

    Explanation: a web server that has PHP installed distinguishes between normal web pages and PHP scripts. If it sees a normal web page, like your home page, it sends that document to the browser. If it sees a PHP script, it doesn't send anything. Instead, it runs the script, since it knows that PHP scripts are computer programs to be run on the web server itself, not documents to be sent. It's then up to the PHP script to send something to the browser if it wants to. When run in this way, the script created by the Feedback Form Wizard notices that it was accessed directly (instead of through the "Send Feedback" button). Since it's twiddling its thumbs, with no email to send, it simply tells your visitor's browser to go to the form instead. That's why you ended up at your contact form.

    (If you encountered a "404 File Not Found" error instead of the form, you've either typed the wrong URL into the browser, or you supplied the wrong address for the "URL of Feedback Form" field in the Wizard when you first created your script.)

Congratulations and Where to Go From Here

Congratulations! You have not only successfully installed a feedback form on your website (a task considered one of the most difficult among new webmasters), you have also completed the design and creation of your entire website. And it's not some trivial play site, but a multi-page, fully functional website with a professional looking navigation menu, a working contact form and site map.

Before you go and celebrate your latest accomplishment, I would appreciate if you would take the time to tell others about by linking to it. Some linking suggestions can be found here, but feel free to link to any page you like. For example, if you like my guide on creating a website, go ahead and link directly to that. Please don't forget as you move on from here with your newfound skills as a webmaster (and your new site).

Incidentally, you can also find additional articles on Expression Web. Those guides are not included in this main tutorial series because they deal with things that not everyone needs to do. Expression Web is a powerful editor with lots of features. If I included everything here, you will be overwhelmed and become discouraged. As such, this main tutorial concentrates on the core set of skills and knowledge needed to design a site, leaving the extra features that only a few people may want to separate standalone articles.

In addition, there is more to website creation than simply designing its pages. A few of the other things to do are mentioned in the guide on How to Create a Website, but you can also take a look at my Site Map to see the list of other articles that deal with frequently required webmaster tasks.

All the best for your site!

Copyright © 2016-2024 Christopher Heng. All rights reserved.
Get more free tips and articles like this, on web design, promotion, revenue and scripting, from

You are here:

Top » Getting Started with Your Website »

How to Create / Make Your Own Website: The Beginner's A-Z Guide » List of All Expression Web Tutorials »

thesitewizard™ News Feed (RSS Site Feed)  Subscribe to newsfeed

Do you find this article useful? You can learn of new articles and scripts that are published on by subscribing to the RSS feed. Simply point your RSS feed reader or a browser that supports RSS feeds at You can read more about how to subscribe to RSS site feeds from my RSS FAQ.

Please Do Not Reprint This Article

This article is copyrighted. Please do not reproduce or distribute this article in whole or part, in any form.

Related Articles

New Articles

Popular Articles

How to Link to This Page

It will appear on your page as:

How to Create a Contact Form with Expression Web

Link to Us
No Spam Policy
Privacy Policy
Site Map

Getting Started
Web Design
Search Engines
Revenue Making
Web Hosting
Perl / CGI
.htaccess / Apache


Free webmasters and programmers resources, scripts and tutorials Free How-To Guides
Site Design Tips at
Find this site useful?
Please link to us.