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
Hi,

I think the best you can do is not using session variables for storing the
input.
Write the form directly to the database.
The reason why the data is shown in other assignments, is that the values
stay
in the session-vars.
If you need the entered data further in the site, just read it from the
form,
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
sessionvar,
and reading the data from the database, where the userID 
session("userID").

Anyway, it isn't recommended to use the sessionvars for data storage,
because
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
for
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
appear
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
work...
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***********

'<html>
....
...
'<BR> <BR>
' <%
  If Request("Update") = "True" Then
    Response.Write "<center>Amend/update your answers <STRONG>Assingmnet
2</STRONG></center><P>"
  Else
    If Request("NotFound") = "True" Then
      Response.Write "<I>You have not started the assignment. " & _
                     "Do you wish to start it now?.</I><P>"
    Else
      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
</Center>"

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

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

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

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

              <input type="hidden" name="hquest1" value="<%= Session
("Question1")%>">
			  <input type="hidden" name="hquest2" value="<%
Session("Question2")%>">
              <input type="hidden" name="hquest3" value="<%= Session
("Question3")%>">
              <input type="hidden" name="hquest4" value="<%= Session
("Question4")%>">
              <input type="hidden" name="AssignConst" value="<%=Asconst %
>">
			  <INPUT TYPE="Submit" VALUE="Submit for Marking">

</FORM>
 <P>
....
...


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

<!--#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,
adCmdTable

  'rsQuestAns.MoveFirst
						...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
variables
  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
  Next
  Session("blnValidUser") = True            ' declare that current user is
validated


  if strQsetNo = "QuestionSet1" then	        	' ... after
updating the DB the user is re-directed
           Response.Redirect "Assignment1.asp"		' ... back to the
assignment they were doing...
  else
	     if strQSetNo = "QuestionSet2" then
		       Response.Redirect "Assignment2.asp"
	     else
		       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
teacher****

NOT YET COMPLETe



  Return to Index