Welcome to my ASP Code Website

ASP Poll Processing Code

Once your user makes a vote in your poll, you need to record their answer in the database along with all other votes. Read How to get a user's poll vote to get the vote from your user.

To update your poll table with this user's vote, you need to know the ID # of the poll they voted on, and which answer they chose. You get that from the previous page. You simply increment your database table to account for their answer! This page would be named poll_p.asp to match the form in the previous example.

Vote = Request("vote")
PollID = Request("pollid")

Dim objCmd9
Set objCmd9 = Server.CreateObject ("ADODB.Command")
SQLText = "UPDATE polls set poll_c" & Vote & " = poll_c" & Vote & " + 1 where poll_id = " & PollID & ";"
objCmd9.ActiveConnection = strConnect
objCmd9.CommandType = &H0001
objCmd9.CommandText = SQLText
objCmd9.Execute intRecords
Set objCmd9 = Nothing

Response.Redirect("Polls.asp?id=" & PollID)

Now that you have updated the poll table, you could show the current results to the user, or just keep it for your own information and say thank you to them.

ASP Poll / Voting Code ASPIsFun Poll Area