p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

proasp_codeclinic thread: somebody, anybody ... please help....

Message #1 by "Abdul Mosobbir" <abdulm7@h...> on Sun, 9 Sep 2001 15:23:26

I think the best you can do is not using session variables for storing the
Write the form directly to the database.
The reason why the data is shown in other assignments, is that the values
in the session-vars.
If you need the entered data further in the site, just read it from the
or, in a later stadium, read it from the database.

The way I usualy work, is storing the login-info (userID, userName etc) in a
and reading the data from the database, where the userID 

Anyway, it isn't recommended to use the sessionvars for data storage,
it uses the server's internal memory.  No problem for a small site,
but if there are a lot of people working on it, the system will slow down.

I hope I could help you with this

Steven Broos
        Project Developer

Netural Design - Web Development and Graphical Design - Antwerpse Steenweg
124, 2640 Aartselaar
netural.be <http://www.netural.be/>  - Tel.: +xx xxx xx xx xx - Fax.: +xx x
238 64 22

-----Original Message-----
From: Abdul Mosobbir [mailto:abdulm7@h...]
Sent: zondag 9 september 2001 15:23
To: Code Clinic
Subject: [proasp_codeclinic] somebody, anybody ... please help....

 I need help please. What i'm trying to do is build a site were kids can
do there
Assignments, save it, login later and edit it and then finaly, submit it
marking... at the moment i can save data and the data is visiable while
they are logged in.......

However, there are two problems:

1..... if the user enter data in one of the assignments, the save it, and
goes to another
assignemnt. Then vaules of Assignemnt 1 appear on Assignemt 2..

2..... when the user logs out and then logins. The entered data does not
on the fields of the Assignemnts the user has saved....

How can I reload the data from the DB for each assignemnt and stop the
values of one
assignment appearing on the other...?

At the moment the codes has no errors, but but still, my program does not
Please advise or show me were i'm going wrong... Thank you in advance...

********* Assignemnt1.asp and Assignment2.asp are the same, but with
different questions***********

'<BR> <BR>
' <%
  If Request("Update") = "True" Then
    Response.Write "<center>Amend/update your answers <STRONG>Assingmnet
    If Request("NotFound") = "True" Then
      Response.Write "<I>You have not started the assignment. " & _
                     "Do you wish to start it now?.</I><P>"
      Response.Write "<CENTER>(If you have finished this assignmtnt, " & _
                     "you might want to start the next one.)</CENTER>"
    End If
 End If
Response.Write "<center>Think and take time in answersing the question

dim Asconst                     ' To be used in the ????Save.asp so the
right Questionset is
Asconst = "QuestionSet2"		' called and updated....

<FORM ACTION="tempSave.asp" NAME="qSet" METHOD="POST">
      <TD WIDTH=20% ROWSPAN=11> </TD>
                    <TD><b>Who is pink?</b></TD>
      <TD><INPUT TYPE="Text" NAME="quest1" VALUE="<%= Session("Question1")%
                    <TD height="29"><b>How have is the Sun?:</b></TD>
                    <TD height="29">
<INPUT TYPE="Text" NAME="quest2" VALUE="<%= Session("Question2")%>"
                    <TD><b>What do ID mean?:</b></TD>
      <TD><INPUT TYPE="Text" NAME="quest3" VALUE="<%= Session("Question3")%
                    <TD><b>which plante do you come from?</b></TD>
      <TD><INPUT TYPE="Text" NAME="quest4" VALUE="<%= Session("Question4")%
    </TR> <input type="hidden" name="AssignConst" value="<%=Asconst %>">

                    <TD ALIGN=CENTER height="53">
                      <input type="Submit" value="Save Your Work"
                      <input type="RESET" name="RESET">
                    <TD ALIGN=CENTER COLSPAN=2 height="53"><BR>

<FORM name="FAform" method="post" action="PermSave.asp">

              <input type="hidden" name="hquest1" value="<%= Session
			  <input type="hidden" name="hquest2" value="<%
              <input type="hidden" name="hquest3" value="<%= Session
              <input type="hidden" name="hquest4" value="<%= Session
              <input type="hidden" name="AssignConst" value="<%=Asconst %
			  <INPUT TYPE="Submit" VALUE="Submit for Marking">


***************TempSame.asp saves the data into a

<!--#include file="Clssfd.asp"-->

  Dim rsQuestAns, strQSetNo
  strQSetNo= Request.Form("AssignConst")
  'Response.Write strQSetNo & " <p>"

  Set rsQuestAns = Server.CreateObject("ADODB.Recordset")
  rsQuestAns.Open strQSetNo , objConn, adOpenStatic, adLockOptimistic,

						...don't need
  rsQuestAns.Filter = "QPersonID = '" & Session("PersonID") & "'"
     If rsQuestAns.EOF Then                                             '
User not found
        rsQuestAns.AddNew                                        ' ...so
add a new record

     End If
  							' write questions
answers in to the record
  rsQuestAns("Question1") = Request.Form("quest1")
  rsQuestAns("Question2") = Request.Form("quest2")
  rsQuestAns("Question3") = Request.Form("quest3")
  rsQuestAns("Question4") = Request.Form("quest4")
  rsQuestAns("QPersonID") = session("PersonID")
  rsQuestAns.Update                                               ' update
the database

  Dim strName, strValue                                   ' create session
  For each strField in rsQuestAns.Fields
    strName = strField.Name
 '   Response.Write strName & " "				' ... test
to see if code works
    strValue = strField.value
 '   Response.Write strValue  & " "
    Session(strName) = strValue
  Session("blnValidUser") = True            ' declare that current user is

  if strQsetNo = "QuestionSet1" then	        	' ... after
updating the DB the user is re-directed
           Response.Redirect "Assignment1.asp"		' ... back to the
assignment they were doing...
	     if strQSetNo = "QuestionSet2" then
		       Response.Redirect "Assignment2.asp"
		       Response.Redirect "Assignment3.asp"
	     End If
  End if


*********** PermSave.asp check the field data with the answers in the DB
and the
show the user their score. It also emails there answers and score to the


  Return to Index