FX Do Vote  (by Felice Di Stefano)
(ASP Js, ASP Vbs, PHP MySQL, PHP ADODB)

The process to do a poll it will be divided in two pages one to vote and one to show the results. This server behavior will add the necessary code to do the vote in a standard poll situation when you give the preference to one of the listed items candidate using a radio group (see demo 1) .

Preparing the page

You may use any of the tables of your database which is suitable for this task, you will need only to add a column to record the votes and name it as you wish, this column must be of the type integer and a default value of 0. It will be required the creation of a table with a single column Varchar 15 to collect all the IPs to avoid that users may vote more than one time and this will give also the number of voters. Remember that for each poll you must have a dedicated IPs table, just name it as you like.
Create a recordsets, one to retrieve the item candidate names and the relative unique identifier like an id. At this point insert a form on the page and inside create the table to list the candidates, one row and two columns will be enough, display the candidate on one column and in the other insert a radio button with an appropriate name, bind the id of the candidate to the checked value field of the radio button. Select the table row and apply the Repeat Region sb of the candidates recordset. Add a submit button outside the loop to complete the form, give a name if DW did not.
Now open the FX Do Vote sb from the FX Poll and Ratings submenu in the server behaviors palette and apply it.

Applying

Form: Select here the used form.
Connection: Select here the used connection, usually the same one used for the recordsets.
Update Table: Select here the candidates table where the rating will be updated.
Rating Column: Select here the column used for the rating or votes to be recorded and updated.
Where Column: Select here the candidate unique identifier usually an id.
Rating Element: Select here the name of the radio button used for the preference.
IP Table: Select here the table used to record the user's IP.
IP Column: Select here the name of the column where IPs are recorded. Since there will be only one column it will be already selected.
Submit Button Name: Select here the name of the button used to submit the form.
Error Msg: Insert here a warning message is the user did not give a preference. Assume that radio buttons will be all unchecked.
Cookie Name: Define the name of a cookie to save the user ip.
Valid Days: Define the number of days the cookie will last. You may want to use a longer time in case you are not sure how long the poll will last. Remember that you cannot exceed the year 2035 otherwise it will work like a date in the past.
Close Poll: This checkbox is used in case you want to close the poll and show only the results. Note that the state of this box must be always the same in both pages, poll and results, otherwise you may risk to achieve an infinite ping pong of the pages.
Redirect To: Define here the redirection page which will be obviously the results page.

It would be a good thing to add a Do Not Cache code in this page. You may find one for PHP here and some for ASP at the Adobe Exchange.

After this create the results page using the object FX Display Rating.

by FELIXONE