Managing Web Surveys with Access

How to create an online survey system on the Internet using Ms Access as the database.

First of all, let’s think about how an online polling system works. The developer of the application (in this case us) provides a topic with the possibility of a closed response. This means that the visitor has the option to choose among the available choices.

Sondaggi sul web, 1

When choosing answers, there are two possibilities. The user can vote for only one option among those available (as in the first step image of this tutorial) or can select multiple items from all those listed as possible answers to the published topic. The latter solution is less common.

Sondaggi sul web, 2

There is also another mode of system development, used very rarely to be honest. This consists of offering the user the possibility to add a personal comment, in addition to multiple answers. Sometimes this can be an option missing from the listed ones, other times a suggestion or an additional comment to the poll.

Sondaggi sul web, 3

Whatever solution is chosen, it is important to decide from the start whether a single user can cast more than one vote or not. Most web polling systems, prepared scripts allow only one opinion per user. There are cases where a visitor can express more votes only if choosing different options.

Sondaggi sul web, 4

If no constraints are set, i.e., every user can cast as many votes as desired, the script would be an easy solution. Each expressed opinion is archived in the database without any further measures. No verification is done to check if the user had already voted.

Sondaggi sul web, 5

It is more complicated to decide if the user can express only one vote. How is this aspect verified? There are different solutions. The most commonly used is definitely based on the visitor’s IP address. With each vote, we register along with the preference, also the IP. At the next vote, we cross-check the already present IPs with the current one: if found, the vote is denied.

Sondaggi sul web, 6

The IP solution has the advantage of being simple to implement but has the drawback of not working if the user has a dynamic IP, or a network where each computer is identified externally by a different address. In such cases, when the IP changes, we could not intercept the vote already cast.

Sondaggi sul web, 7

Another plausible solution is to deposit a cookie on the user’s computer who votes the poll. This is an interesting possibility, because even with a dynamic IP, if the user disconnects and then reconnects to the Internet, the cookie would remain. However, cookies can be easily deleted and not all users accept them.

Sondaggi sul web, 8

The last among the most used possibilities is represented by the user registering to an online Community, like many that exist. Once registered, among the various services offered, the reader could also cast their vote in the poll, only after logging in. Thus, with each vote, there would be only one registered user.

Sondaggi sul web, 9

The vote verification system through registration to a Community is widely used within those Forums that allow creating polls, even by the users themselves. An example is the PHP application vBulletin (http://www.vbulletin.com), a Forum whose members can create polls and vote in them.

Sondaggi sul web, 10

The poll we will see in our example (by Matteo Stori) allows only one vote per user, relying on cookies. This is because the best solution for us (registration) does not make sense unless other useful services are offered to encourage the user to sign up. Almost no one would register on a site just to vote in a poll.

Sondaggi sul web, 11

The system we will use is based on Access as the repository of collected data. As always, when it comes to choosing data support, it is important to weigh possible solutions and choose the one best suited to your needs. A poll must be able to be added, removed, and modified on the fly without obstacles. Access, in this case, is very quick (it can be removed with one click).

Sondaggi sul web, 12

The structure of the application we will present is based on two tables. The first, called “nomesondaggio” contains only and exclusively the name of the poll (this system supports one poll at a time). The second, called “etichette,” lists the various options among which to choose your vote.

Sondaggi sul web, 13

Now let’s see the data structure. In the first table, the field “nomesondaggio” is Text type, 50 characters (but can be extended if needed). In the second table, the field “etichetta” is Text (50 characters), then “id_etichetta,” an AutoNumber with Primary Key. Finally, “opzioni,” a Number type (Long Integer).

Sondaggi sul web, 14

We have seen the present data and the data types we are interested in to create a simple online polling system with Microsoft Access. There are few data present because in the database we only need to save the poll title and the allowed options, among which the user will then choose.

Sondaggi sul web, 15

To avoid having to download and upload the .mdb file each time the poll is modified, it is necessary to have a web control panel that allows us to change the poll title, or the various options, directly online.

Sondaggio sul web, 16

What exactly can we do from this online control panel? The first thing is to modify the poll title, that is, the question to which the users will respond. This is the first feature offered by the panel, inside the first top box.

Sondaggio sul web, 17

The second possibility offered by the control panel is to add new labels, i.e., new options among which users can choose. To do this, specify the number of new entries to add and then modify the created field (which by default takes a number) with the chosen value.

Sondaggi sul web, 18

We have seen that to add an option, it implicitly requires knowing how to modify the new entry created. So let’s see how to change one of the options: insert the new text next to the entry to be changed and then press the “Submit” button at the bottom of the page.

Sondaggi sul web, 19

Of course, it is also possible to delete one of the entries present in the poll. This is done when a wrong option was added or to create a new questionnaire, it is found that there are too many entries. To delete one or more, check the boxes (technically checkboxes) next to the options and then press the usual “Submit” at the bottom of the page.

Sondaggi sul web, 20

A question many readers might ask is about the IP address. That is, why save that numeric value of the visitor commenting? First of all, to warn the commenter not to abuse the service. Secondly, to pass this value (along with time and date) to the competent authorities in case of complaints.

Sondaggi sul web, 21

Before voting, you can also check how the poll is going (this is a public option in this system, available to all visitors). Simply click the “results” link at the bottom of the sondaggio.asp page to get data extracted directly from the database.

Sondaggi sul web, 22

Once you have cast your vote, updated results including the last vote cast will be returned (as in the image from the previous step). If the vote was already expressed, it will not be recorded in the database and a new page will appear with the text “You have already voted.”

Sondaggi sul web, 23

Pubblicato in

Se vuoi rimanere aggiornato su Managing Web Surveys with Access iscriviti alla nostra newsletter settimanale

Be the first to comment

Leave a Reply

Your email address will not be published.


*