Forums

ASP

This topic is locked

cookies ans session

Posted 05 Sep 2006 08:24:20
1
has voted
05 Sep 2006 08:24:20 Sakina Allawati posted:
Hello

I's trying to make a survey.
I want whenever a user submit an answer he/she can not submit the answers for the same question again(only once).
this may done by cookies or session but I don't know how to do it and where should i place it.

Can anyone help me
please I want the answer soon

these are my pages and there are more but similar to these.



<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/survey_conn.asp" -->


<%
Dim rsQues1
Dim rsQues1_numRows

Set rsQues1 = Server.CreateObject("ADODB.Recordset"
rsQues1.ActiveConnection = MM_survey_conn_STRING
rsQues1.Source = "SELECT * FROM questions WHERE question_no=1"
rsQues1.CursorType = 0
rsQues1.CursorLocation = 2
rsQues1.LockType = 1
rsQues1.Open()

rsQues1_numRows = 0
%>
<%
Dim rsAnswer1
Dim rsAnswer1_numRows

Set rsAnswer1 = Server.CreateObject("ADODB.Recordset"
rsAnswer1.ActiveConnection = MM_survey_conn_STRING
rsAnswer1.Source = "SELECT answers.answer_no, answers.Question_No, answers.answers, answers.counts FROM answers, questions WHERE questions.Question_No= answers.Question_No and questions.question_no=1"
rsAnswer1.CursorType = 0
rsAnswer1.CursorLocation = 2
rsAnswer1.LockType = 1
rsAnswer1.Open()

rsAnswer1_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsAnswer1_numRows = rsAnswer1_numRows + Repeat1__numRows
%>

<html>
<head>
<title>Question1</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#666666">
<tr>

</tr>
</table>
<table width="100%" border="0">
<tr>
<td><p align="left"><strong><%=(rsQues1.Fields.Item("About".Value)%>:</strong></p>
<p><%=(rsQues1.Fields.Item("Question".Value)%> </p></td>
</tr>
<tr>
<td height="144">
<form method="get" action="localhost:88/survey_page/voting.asp" name="vote" >
<table width="346" >
<tr valign="baseline">
<td width="81" align="right" nowrap> </td>
<td colspan="2"><%=(rsQues1.Fields.Item("QUEST_DATED".Value)%> </tr>
<tr valign="baseline">
<td nowrap align="right">Question No:</td>
<td width="186"><%=(rsAnswer1.Fields.Item("Question_No".Value)%></td>
<td width="63">Counts:</td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT rsAnswer1.EOF))
%>
<tr valign="baseline">
<td nowrap align="left"> 
</td>
<td valign="top">
<input type="radio" name="answers" value=<%=(rsAnswer1.Fields.Item("answer_no".Value)%> checked >
<option value="<%=(rsAnswer1.Fields.Item("answer_no".Value)%>"><%=(rsAnswer1.Fields.Item("answers".Value)%></option>       </td>
<td valign="top"><input type="text" name="counts" value="<%=(rsAnswer1.Fields.Item("counts".Value)%>" size="10"></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsAnswer1.MoveNext()
Wend
%>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td colspan="2"> <input name="submit" type="submit" value="Vote">
</td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
</form>
</td>
</tr>

<TR align="left">
<TD colspan="2" valign="middle" class="text"></TD>
</TR>
</table>

</body>
</html>
<%
rsQues1.Close()
Set rsQues1 = Nothing
%>

<%
rsAnswer1.Close()
Set rsAnswer1 = Nothing
%>


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/survey_conn.asp" -->
<% if request.form("radio" <> "no" then %>
<%
set cmdUpdateAns = Server.CreateObject("ADODB.Command"
cmdUpdateAns.ActiveConnection = MM_survey_conn_STRING
cmdUpdateAns.CommandText = "UPDATE answers SET counts = counts + 1, ANS_LAST_VOTE = date() WHERE answer_no = "& request.querystring("answers"
cmdUpdateAns.CommandType = 1
cmdUpdateAns.CommandTimeout = 0
cmdUpdateAns.Prepared = true
cmdUpdateAns.Execute()



Response.Redirect("localhost:88/survey_page/question2.asp")
%>
<% Else
Response.Redirect("localhost:88/survey_page/question1.asp?action=voted")
%>

<%End If%>



thank you

Reply to this topic