Flash + ASP wonderful joint creation of voting program (Figure)

Source: Internet
Author: User
Tags table name tag name
To investigate the position of site visitors on specific questions, we can set a voting program on the site. Site visitors directly select the answer, and the program will automatically count and display all the answers.
The following is a simple voting program for the flash version. xml + asp + mysql is used in the background: because most web jobs
Users are familiar with asp. xml can simplify complicated problems. The reason for using mysql is that access is not installed and the program does not need any stored procedures. Therefore, SQL Server is not required, oracle and other weapons.
Problem Analysis: This voting program is a multiple-choice question, so we can use a field to store users' answers.
Create a database and a table: The table name and database name are arbitrary. The fields are defined as follows:
Voteid, unsigned integer, automatic number
Result Short integer storage the user selected the program range is 0-2
Userip char (25) the actual length of the user IP address is 21
Message char (255) additional message // This program is not used
Create With mysql-front, as shown in the following figure:
Figure 1
Design the flash user interface: drag three RadioButton files from window/components/flash ui components to the stage.
Set the tag. The others are the default values. (You can set both the property panel and component parameter panel)
Figure 2
Here we will use a chart component (Subtype in html ui Components). You can go to MM to expand the resource www.macromedia.com/exchange/flashdownload.
The parameter settings are as follows:
Figure 3
 
Figure 4
Flash-side programs are very simple with only three lines:
// Add the following code to the first frame of the timeline
// The tag name is "start voting !" The event handle is sendvote. After clicking, execute the following custom function.
Function sendvote (){
_ Root. mytb. readData ("http: // localhost/votexml. asp? Selectresult = "+ radioGroup. getInstance ());
}
Compile the server program. You may see a votexml. asp file above. Let's create 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 = '" & userip & "'", conn
If rec ("count")> 0 then
Bzh = "invalid repeated voting"
Rec. close
'Response. Write ("Please do not vote again ")
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.