Populate form with previously submitted information

I have a form which asks for some personal information. Then an option to select a type with additional information to enter. Once the form is complete, the user submits the data and it is entered in an MSDatabase and sent via email. On the submit page, I want to include an option to submit another request (line 243) and automatically include the users personal information. There are 5 fields I want to include (ILLRequestorsFName, ILLRequestorsLName, ILLRequestorsService, ILLRequestorsEmail, ILLRequestorsPhone).

The form is Eligible.asp.
The confirmation page is Eligible2.asp

I am including the code for Eligible2.asp.

<%@LANGUAGE="VBSCRIPT"%>

<!-- #Include Virtual="CodeReuse/ConnTesting.inc" -->

<%
'response.Write("chartID: " & session("ChartID"))
'response.End()
%>

<%
dim title
title = "Form"

'--------------------------------------------------------------------------------------------
dim ChartID
ChartID = session("ChartID")
	

'--------------------------------------------------------------------------------------------
dim sql2, RSListRecipients
	
	sql2= "SELECT SDEmail FROM tblStaffDirectory WHERE ChartID=" & ChartID & " and ILLContact='Y'"

'response.Write("sql2: " & sql2)
'response.End()
			
		set RSListRecipients = objConn.Execute(sql2)


'--------------------------------------------------------------------------------------------

'insert the information from the previous page into the database

dim objRS, strCol, ILLID

'open recordset
'open recordset where the data from the previous page will be stored


sql = "Select * FROM tblILLRequests WHERE (ILLID = " & Request.form("ILLID") & ")"

	Set objRS = Server.CreateObject("ADODB.Recordset")
	objRS.Open "tblILLRequests", objConn, adOpenStatic, adLockOptimistic, adCmdTable

	'Crete new record.
	objRS.AddNew
	'Input data in tblILLRequests.
	For each strCol in Request.Form
		If Len(Request(strCol)) > 0 then
				objRS(strCol) = Request.Form(strCol)
			End If
	Next
'Write the record to the database.
objRS.Update

'Get the unique ID of the record we just created. 
'We'll use this ID in the other tables, and will pass it to subsequent pages in a hidden form field.

Set objRS = objConn.Execute( "SELECT @@IDENTITY" )
ILLID = objRS(0)

objRS.close


'---------------------------------------------- Mail function ---------------------------------------
'Following is code to send email

dim strRecips
strRecips = "email@gmail.com"


While Not RSListRecipients.EOF
'Following line displays the requestor's email
	response.Write("<br/>" & RSListRecipients("SDEmail"))
	strRecips = strRecips & RSListRecipients("SDEmail") & ";"
	RSListRecipients.MoveNext
Wend

'following line displays WHO the message is sent to
'Response.Write("<br/>" & strRecips)

txtTo = strRecips



'---------------------------------------------- Body of email ---------------------------------------
txtFrom = request.form("ILLRequestorsEmail")

txtSub = "ILL Online Request"

txtBody = "Requestor's Name: " & request.form("ILLRequestorsFName") & " " & request.form("ILLRequestorsLName")
txtBody = txtBody & "<br>Service: " & request.form("ILLRequestorsService")
txtBody = txtBody & "<br>Email: " & request.form("ILLRequestorsEmail")
txtBody = txtBody & "<br>Phone: " & request.form("ILLRequestorsPhone")

	txtBody = txtBody & "<p>&nbsp;&nbsp;Type of Request: " & request.form("ILLRequestType")

	IF request.form("ILLRequestType") = "Book" THEN
		txtBody = txtBody & "<p>&nbsp;&nbsp;Book Author: " & request.form("ILLBookAuthor")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Book Title: " & request.form("ILLBookTitle")
		txtBody = txtBody & "<br>&nbsp;&nbsp;ISBN: " & request.form("ILLBookISBN")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Book Chapter: " & request.form("ILLBookChapter")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Book Chapter Pages: " & request.form("ILLBookChapterPages")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Publisher: " & request.form("ILLBookPublisher")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Publication Date: " & request.form("ILLBookPubYear")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Edition: " & request.form("ILLBookEd")
	END IF
	
	IF request.form("ILLRequestType") = "Audiovisual" THEN
		txtBody = txtBody & "<p>&nbsp;&nbsp;Audiovisual Title: " & request.form("ILLAVTitle")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Producer: " & request.form("ILLAVProducer")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Production Year: " & request.form("ILLAVProductionYear")
	END IF
	
	IF request.form("ILLRequestType") = "Journal Article" THEN
		txtBody = txtBody & "<p>&nbsp;&nbsp;Journal Title: " & request.form("ILLJournalTitle")
		txtBody = txtBody & "<br>&nbsp;&nbsp;ISSN: " & request.form("ILLJournalISSN")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Volume: " & request.form("ILLJournalVolume")
		txtBody = txtBody & "&nbsp;&nbsp;Issue: " & request.form("ILLJournalIssue") 
		txtBody = txtBody & "&nbsp;&nbsp;Publication Date: " & request.form("ILLJournalPubDate") 
		txtBody = txtBody & "<br>&nbsp;&nbsp;PMID: " & request.form("ILLJournalPMID")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Journal Article: " & request.form("ILLJournalArticle")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Author: " & request.form("ILLJournalArticleAuthor")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Page range: " & request.form("ILLJournalPages")
	END IF

		txtBody = txtBody & "<br>&nbsp;&nbsp;Not needed after: " & request.form("ILLNotNeeded")
		txtBody = txtBody & "<br>&nbsp;&nbsp;Additional Info: " & request.form("ILLInfo")




%>

  <!-- #INCLUDE VIRTUAL="CodeReuse/Mailer2.asp" -->


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title><%=title%></title>


<link rel=stylesheet type="text/css"
  href="CodeReuse/style.css">


</head>

<body>

<h2><%=title%> - Request Submitted</h2>


<p>&nbsp;</p>

<hr>


<div id="LrgPrt"><p align="center">

	Thank you for using the <b><i>Online Interlibrary Loan form</i></b>.
	<br>Your request has been sent to your facility library staff.

<hr>

<%
Response.Write "The following data has been submitted<p>"

Response.Write "<blockquote>"

Response.Write "<b>Name: </b>" & request.form("ILLRequestorsFName") & " " & request.form("ILLRequestorsLName")

If LEN(Request.form("ILLRequestorsService"))>0 THEN
	Response.Write "<br><b>Service: </b>" & request.form("ILLRequestorsService")
End If

Response.Write "<br><b>Email: </b>" & request.form("ILLRequestorsEmail")

If LEN(Request.form("ILLRequestorsPhone"))>0 THEN
	Response.Write "<br><b>Phone: </b>" & request.form("ILLRequestorsPhone")
End If


'---------------------------- Verification of AV Request ----------------------------
IF request.form("ILLRequestType") = "Audiovisual" THEN
	Response.Write "<blockquote><b>Audiovisual Request</b><br>"
		Response.Write "<br><b>Audiovisual Title: </b>" & request.form("ILLAVTitle")
		Response.Write "<br><b>Producer: </b>" & request.form("ILLAVProducer")
		Response.Write "<br><b>Production Year: </b>" & request.form("ILLAVProductionYear")

		Response.Write "<br><b>Not needed after: </b>" & request.form("ILLNotNeeded")
		Response.Write "<br><b>Additional Info: </b>" & request.form("ILLInfo")

	Response.Write "</blockquote>"
END IF
	

'-------------------------- Verification of Journal Request --------------------------

IF request.form("ILLRequestType") = "Journal Article" THEN
	Response.Write "<blockquote><b>Journal Article Request</b><br>"
		Response.Write "<br><b>Journal Title: " & request.form("ILLJournalTitle")
		Response.Write "<br><b>ISSN: " & request.form("ILLJournalISSN")
		Response.Write "<br><b>Volume: " & request.form("ILLJournalVolume")
		Response.Write "<br><b>Issue: " & request.form("ILLJournalIssue") 
		Response.Write "<br><b>Publication Date: " & request.form("ILLJournalPubDate") 
		Response.Write "<br><b>PMID: " & request.form("ILLJournalPMID")
		Response.Write "<br><b>Journal Article: " & request.form("ILLJournalArticle")
		Response.Write "<br><b>Author: " & request.form("ILLJournalArticleAuthor")
		Response.Write "<br><b>Page range: " & request.form("ILLJournalPages")

		Response.Write "<br><b>Not needed after: </b>" & request.form("ILLNotNeeded")
		Response.Write "<br><b>Additional Info: </b>" & request.form("ILLInfo")

	Response.Write "</blockquote>"
END IF


'-------------------------- Verification of Book Request --------------------------

IF request.form("ILLRequestType") = "Book" THEN
	Response.Write "<blockquote><b>Journal Article Request</b><br>"
		Response.Write "<br><b>Book Author: " & request.form("ILLBookAuthor")
		Response.Write "<br><b>Book Title: " & request.form("ILLBookTitle")
		Response.Write "<br><b>ISBN: " & request.form("ILLBookISBN")
		Response.Write "<br><b>Book Chapter: " & request.form("ILLBookChapter")
		Response.Write "<br><b>Book Chapter Pages: " & request.form("ILLBookChapterPages")
		Response.Write "<br><b>Publisher: " & request.form("ILLBookPublisher")
		Response.Write "<br><b>Publication Date: " & request.form("ILLBookPubYear")
		Response.Write "<br><b>Edition: " & request.form("ILLBookEd")

		Response.Write "<br><b>Not needed after: </b>" & request.form("ILLNotNeeded")
		Response.Write "<br><b>Additional Info: </b>" & request.form("ILLInfo")

	Response.Write "</blockquote>"
END IF
	

%>

Submit another request
<p>

</div>

        
</body>

</html>

Open in new window

Malloy1446Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John_VidmarCommented:
Save the values in a form with hidden-fields; the submit-button (line 243) would be replaced with the following:
<form action="Eligible.asp" >
	<input type="hidden" name="ILLRequestorsFName"   value="<%=request.form("ILLRequestorsFName")%>"   />
	<input type="hidden" name="ILLRequestorsLName"   value="<%=request.form("ILLRequestorsLName")%>"   />
	<input type="hidden" name="ILLRequestorsService" value="<%=request.form("ILLRequestorsService")%>" />
	<input type="hidden" name="ILLRequestorsEmail"   value="<%=request.form("ILLRequestorsEmail")%>"   />
	<input type="hidden" name="ILLRequestorsPhone"   value="<%=request.form("ILLRequestorsPhone")%>"   />
	<input type="submit" value="Submit another request" />
</form> 

Open in new window

0
Malloy1446Author Commented:
I tried the suggested code with just one field. It returns to the Eligible.asp page with the following URL:

Eligible.asp?ILLRequestorsFName=bbb

Although the field is NOT filled in.
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
do you have code on your form fields to read in these values? I would also change the form's method to POST:

eligible2.asp - line 243
<form action="Eligible.asp" method="POST" >
	<input type="hidden" name="ILLRequestorsFName"   value="<%=request.form("ILLRequestorsFName")%>"   />
	<input type="hidden" name="ILLRequestorsLName"   value="<%=request.form("ILLRequestorsLName")%>"   />
	<input type="hidden" name="ILLRequestorsService" value="<%=request.form("ILLRequestorsService")%>" />
	<input type="hidden" name="ILLRequestorsEmail"   value="<%=request.form("ILLRequestorsEmail")%>"   />
	<input type="hidden" name="ILLRequestorsPhone"   value="<%=request.form("ILLRequestorsPhone")%>"   />
	<input type="submit" value="Submit another request" />
</form> 

Open in new window


eligible.asp - whatever line your field is on:
<input type="text" name="ILLRequestorsFName" value="<%=Request("ILLRequestorsFName")%>" />

Open in new window

0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Malloy1446Author Commented:
On eligible.asp I added the value.
On eligible2.asp my form code

<form action="Eligible.asp" method="POST">
	<input type="hidden" name="ILLRequestorsFName" value="request.form('ILLRequestorsFName')" />
	<input type="submit" value="Submit another request" />
</form>

Open in new window


When I click Submit, Eligible.asp displays request.form('ILLRequestorsFName') on the form
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
be sure to look at the code I posted carefully. You need to add it inside <% %> tags:

<input type="hidden" name="ILLRequestorsFName" value="<%=request.form('ILLRequestorsFName')%>" />
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Another options is in your insert code you are grabbing the an the identity id for tblILLRequests on line 60
ILLID = objRS(0).

Open in new window

You could also submit the field ILLID as a hidden field, session variable or cookie.  Then in your processing page, look up the data you need from tblILLRequests and copy it over.  

One advantage to this method is you will know for sure the personal data is not altered.  Even if you use a hidden field, it is still subject to change and as a rule you shouldn't trust input data.  

Still another option is to simply add a field "OriginalRquestID" and make the default value in your db zero.   When you submit the 2nd or any subsequent request, use the field ILLID to populate.  Then you can always grab the personal information from the original request.  As a side benefit, you track how many related requests are being made.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.