Learn to do online surveys with me (Iv.)

Source: Internet
Author: User
Tags exit modify
Online continuation of the article
In the previous article, we completed the display of statistical results and survey list of procedures, and finally we completed the background
Management page, is also the most important one program.

First, backstage management
In the admin page survey_manage.asp, we've already listed what it's going to achieve
management functions. The process of management is to show all the investigations first, for the investigations that have not yet begun, can be repaired
(a) Change or deletion; For an investigation that has been completed, it can be deleted and cannot be modified; For ongoing investigations, only
Can modify its end time. The action is represented by a parameter action, meaning the following:
1, no parameters. Represents the first entry, displaying the login form
2, login means to perform login
3, logout sign to perform exit login
4, Showaddquestion said to show an increase in the survey
5, Showsurvey show a survey
6, Doaddsurvey said that the implementation of an additional investigation
7, Doaddanswer said the implementation of an additional answer
8, Dodelsurvey said to delete a survey
9, Dodelanswer said to delete an answer
10, Domodify said to revise a survey and answer

<!--#include file= "inc.asp"-->
<%
Opendb my ' Open database
' Get the parameters. Action represents actions, respectively, corresponding to the above functions.
Action=request.querystring ("Action")
Id=request.querystring ("id")
' Get the current file name
Scr=request.servervariables ("Script_name")
' Move to the appropriate subroutine according to the action
Select Case Action
Case "Login"
Login () ' Execute login
Case "Logout"
Logout () ' Perform exit login
Case "Doaddsurvey"
Doaddsurvey () ' executive adds an investigation
Case "Dodelsurvey"
Dodelsurvey () ' Execute deletes a survey
Case "Dodelanswer"
Dodelanswer () ' Execute delete an answer
Case "Domodify"
Domodify () ' Execute modify a survey and answer
End Select
'----Login subroutine----
Sub Login ()
Username=request.form ("username") ' Get user name
Password=request.form ("password") ' Get password
If username<> "" and password<> "" Then
Sql= "SELECT * from Manage where manage_username= '" & Username & "" "Query users
Searchtable My,sql,rs
If not rs.eof then ' if there is
If RS ("Manage_password") =password Then ' password is also correct
Session ("Survey_login") =true ' login
End If
End If
CloseTable rs ' Close table
End If
Response.Redirect SCR ' No login, finally back to admin page
End Sub
'----Exit Login subroutine----
Sub Logout ()
' Delete Session variable
Session.contents.remove "Survey_login"
Response.Redirect SCR ' Back to admin page
End Sub
'----Perform an increase in the survey subroutine----
Sub Doaddsurvey ()
Question=request.form ("question")
Stime=request.form ("Stime")
Etime=request.form ("ETime")
Stype=request.form ("Stype")
If question<> "" and Stime<> "" and Etime<> "" and IsDate (stime) _
and IsDate (ETime) and session ("Survey_login") Then
Sql= "SELECT * from survey where survey_id is null"
Changetable My,sql,rs
Rs.addnew
RS ("Survey_question") =question
RS ("Survey_stime") =cdate (stime)
RS ("Survey_etime") =cdate (ETime)
RS ("Survey_type") =cbool (Stype)
Rs.update
Id=rs ("survey_id")
CloseTable RS
Response.Redirect scr& "? action=showsurvey&id=" &id ' Back to display page
End If
Response.Redirect SCR ' Back to display page
End Sub

'----Execute the additional survey answer subroutine----
Sub Doaddanswer ()
Answer=request.form ("Newanswer")
If session ("Survey_login") Then
Sql= "SELECT * from Survey_vote where vote_no is null"
Changetable My,sql,rs
Rs.addnew
RS ("Vote_answer") =answer
RS ("vote_id") =id
Rs.update
CloseTable RS
End If
' Response.Redirect scr& '? action=showsurvey&id= ' &id ' back to the display page
End Sub

'----to perform a change investigation subroutine----
Sub Domodify ()
Question=request.form ("question")
Stime=request.form ("Stime")
Etime=request.form ("ETime")
Stype=request.form ("Stype")
Answer=request.form ("Newanswer")
If session ("Survey_login") Then
Sql= "SELECT * from survey where survey_id=" &id
Changetable My,sql,rs
If not rs.eof then
If Question<> "" Then RS ("Survey_question") =question
If stime<> "" "and IsDate (stime) then RS (" Survey_stime ") =cdate (stime)
If etime<> "" and IsDate (etime) Then
If CDate (etime) >rs ("Survey_stime") then RS ("Survey_etime") =cdate (ETime)
End If
If Stype<> "" Then RS ("Survey_type") =cbool (Stype)
Rs.update
End If
CloseTable RS
If answer<> "" Then Doaddanswer ()
Sql= "Select Vote_answer from Survey_vote where vote_id=" &id
Changetable My,sql,rs
For I=1 to Rs.recordcount
If Request.Form ("no" &i) <> ""



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.