We've all come across some sort of online survey that asks a few questions about our interests or our online shopping experience. In this article we're going to walk you through the creation of a similar online survey that you can use on your own web site.

Basically we're going to create a survey of 10 to 12 questions that gather information about the user, as well as their views and opinions. We'll do this in two ways. The first way we're going to do this is to email a reader the survey results. They will be formatted in a readable manner, and then emailed using PHP's internal mail() function.

The other way we're going to collect the data is by storing it in a database. Instead of making it so only one person sees the results, we'll also create a results page and calculate exactly how many people have voted for each answer.

Setting Up the Survey

To begin, we need to think of some basic survey questions. I've come up with 10 questions for our users to answer about the support they just received. This is just a typical survey about user satisfaction. Here are the questions we're going to use:

  • What is your gender?
  • What is your age group?
  • Was this phone or email support?
  • What is your knowledge of computers?
  • Overall how satisfied are you with the support you received?
  • How satisfied are you with the speed of the support?
  • How would you rate the knowledge of the support representative?
  • Would you recommend us to a friend or coworker for support requests in the future?
  • How satisfied were you with the result of the support?
  • How would you rate the personability of the support representative?
Now that we know what questions we're going to ask, let's think of a scale. I'm going to use the general scale of:
Very-Dissatisfied | Dissatisfied | Satisfied | Very Satisfied | Neutral
So, now that we have a scale, we can set up our HTML page. Here is how the HTML code appears:

click to open new window to view the HTML code

As you can see, we've got a table with our questions and answers as radio buttons, and a submit button. When the user answers all the questions and clicks submit, they will be taken to "process.php" and that's where we'll grab their response and email out the information.

[ Next ]