passing variables from first page to third

T

t-ball

I am new to the world of ASP, and at the same time VBscript (also a
firt time poster).

I am currently creating a multiple page form where the information on
the first page needs to be validated. To do this, I have an asp page
between the 1st and second pages of the form. However, I need to pass
all of the information from the 1st page to the third (the second page
of the form) so that all collected information can be sent out in an
e-mail.

I thought about doing this with hidden form fields, but I don't know
if this is possible. I put a form with hidden fields on the
validation page, but I don't know how to make it forward to the proper
page after that without a submit button.

I have also heard of session variables, but I could not find too much
information on the topic.

If you know of any ideas or references that will help me, it would be
greatly appreciated.

Sorry again that I am such a beginner at this topic.

Thanks.
 
T

Tom B

Generally, I'd put all of that in one page, that posts to itself.

Example........


<%
Dim sName
Dim sNameErr
if Request.Form("postback")="true" then
if ValidateData() then
SaveData
Response.redirect("alldone.asp")
end if
end if
%>
<Form method=Post Action="thisHerePage.asp">
<input type=hidden name="postback" value="true">
Your Name:<input name=Name value=<%=sName%>><%=sNameErr%><br>
<input type=Submit Value="Save">
</Form>
<%
Function ValidateData()
bRetVal=true

'Do validation stuff....
sName=Request.Form("Name")
if len(sName)=0 then
bRetVal=false
sNameErr="Required Field"
end if

ValidateData=bRetVal
End Function

Sub SaveData()
'Save the data somewhere
End Sub

%>
 
T

Tricia Castrogiovanni

I could validate in the on the same page as the first form and redirect
to the second page of the form (a good idea that I never thought of),
but then how do I get the data to the second page?

As I stated in my first post, I will be e-mailing all of the data out,
so I will need it all in one place at one time. Is there a way I can do
this with the method you suggested?

Thanks
 
T

Tom B

If you take a look at what I posted, you'll notice that if the data is
validated successfully then the SaveData subroutine is called. Rather than
saving the data though, you would just send your email in that subroutine.

Basically the user will hit the same page 2 or more times
1st time--user enters their information
2nd time -- page is validated--if it's valid, then it saves the data/emails
the data then redirect to the "all done" page.
-- if it's not valid, the initial page is presented again,
with the error messages.
3rd and up time -- same as 2nd, if it's valid, save/email, if not, show it
again.

Wait a sec......
Are you saying, that Page1 collects some information, then Page 2 collects
more information (but different)?
If so, then you have a couple of choices.
Choice 1, save all the Page1 data in hidden form fields
Choice 2, save in Session variables
Dim sName
sName=Request.Form("Name")
if IsValid(sName) then 'some validating script
Session("Name") = sName
end if
then on the third page you retrieve with sName=Session("Name")
Choice 3, after page 1 is submitted you store the page1 data in a database
and retrieve on Page 3
with this method you still need to keep track of the data.
Again, either with a Session variable or Hidden form field
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top