flash+asp Joint voting process (figure)

Source: Internet
Author: User
Tags count end integer mysql tag name
Program | Vote for the survey to understand the site visitors to the specific issue of the position, we can set up a polling site, site visitors directly choose the answer, the program automatically to all the answers to statistics and display.

Below is a simple flash version of the voting program, backstage using xml+ asp+ MySQL: Because most web work
Are familiar with ASP, XML can simplify complex problems, using MySQL because access I did not install, the program does not require any stored procedures, so do not need to move SQL Server, Oracle and other heavy weapons.

Problem analysis: This voting procedure is the choice question, therefore we use a field to store the user's answer.

Create databases and tables: table names and database names are arbitrary, and fields are defined as follows:

Voteid unsigned integer autonumber

Result short integer storage user Select this program range in 0-2

Userip Char (25) User IP address actual length 21

Message char (255) Append//This program is not used

Create using Mysql-front, as shown in the following illustration:


Figure 1


Design the Flash user interface: Drag three RadioButton from the Window/components/flash UI components to the stage,

Set the label, others as the default value. (Can be set from both the property panel and the component parameters panel)


Figure 2


Here you will use a Chart component (subtype in the HTML UI components), and you can www.macromedia.com/exchange/flash the download to the MM extension resource.
The parameters are set as follows:


Figure 3




Figure 4


Flash end of the program is very simple only three lines:

In the first frame of the timeline, add the following code

The tag name is "Start voting!" button, the event handle is Sendvote, and after clicking, execute the following custom function

function Sendvote () {

_root.mytb.readdata ("http://localhost/votexml.asp?selectresult=" +radiogroup.getinstance ());

}

Server-side program to write, you may see a votexml.asp file, below we will build it.

The code is as follows:
<% @LANGUAGE = "VBSCRIPT" codepage= "936"%>
<%
Set Conn=server. CreateObject ("Adodb.connection")
Conn.Open "Dsn=mysql"
Set Rec=server. CreateObject ("Adodb.recordset")
%>
<% If Request ("Selectresult") <> "" Then
userip= Request.ServerVariables ("REMOTE_ADDR")
Selectresult=request. QueryString ("Selectresult")
Rec.open "SELECT COUNT (*) as Count from votetable where votedate> '" &now () -0.125 & "' and userip= '" &AMP;USERIP&A MP; "'", Conn
If Rec ("Count") >0 Then
Bzh= "Repeat ballot invalid"
Rec.close
' Response. Write ("Please do not repeat the vote")
Else
Rec.close
Bzh= "Vote valid"
Conn.execute "INSERT into votetable (Userip,result) VALUES (' &userip& '," & selectresult& ")"
End If
Else
Bzh= "View Polls"
End If
Rec.open "SELECT result,count (*) as Count from votetable GROUP by result ASC", Conn
T0=cint (Rec ("Count")
Rec.movenext
T1=cint (Rec ("Count")
Rec.movenext
T2=cint (Rec ("Count")
Tcount=t0+t1+t2
Response.contenttype= "Text/xml"
%>
<% Response.Write " -->"
Response. Write (" ")
Response.Write " "
Response. Write (" ")
Response. Write (" ")
Response. Write (" ")
Response. Write (" ")
%>
<%
Response.Write " "
Rec.close
Set rec=nothing
Conn.close
Set conn=nothing
%> Save the file as a votexml.asp, and place it in a directory where the Web path is "/". Note: When actually applied to a Web server, use a relative path in Flash. Flash movie and votexml.asp can be placed in any directory.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.