call post w/ classic asp

J

jp2code

I've got a form that posts to itself when submitted.

Right now, after the form is submitted, the code checks that all of its
fields are valid, then processes the information. If all goes well, visitors
are then redirected using Response.Redirect("thanks.asp").

What I'd like to do is replace Response.Redirect("thanks.asp") with
something more like the post that happens on the form so that "thanks.asp"
can display a summary of what was submitted.

Is there a way to do this? Can you call a "post" somehow from Classic ASP?

I have not spent a lot of time with ASP, so it could be something simple!
 
T

Tim Slattery

jp2code said:
I've got a form that posts to itself when submitted.

Right now, after the form is submitted, the code checks that all of its
fields are valid, then processes the information. If all goes well, visitors
are then redirected using Response.Redirect("thanks.asp").

What I'd like to do is replace Response.Redirect("thanks.asp") with
something more like the post that happens on the form so that "thanks.asp"
can display a summary of what was submitted.

Is there a way to do this? Can you call a "post" somehow from Classic ASP?

No. IMHO the best way to handle this is to store the data from the
form into the session object (Session("myvar")=whatever). Then the
page you forward to can retrieve the data from there and do whatever
it wants with it.
 
M

Mike Brind

jp2code said:
I've got a form that posts to itself when submitted.

Right now, after the form is submitted, the code checks that all of its
fields are valid, then processes the information. If all goes well,
visitors are then redirected using Response.Redirect("thanks.asp").

What I'd like to do is replace Response.Redirect("thanks.asp") with
something more like the post that happens on the form so that "thanks.asp"
can display a summary of what was submitted.

Is there a way to do this? Can you call a "post" somehow from Classic ASP?

Instead of Response.Redirect, use Response.Write to summarise what was
submitted. Yes, it really is that simple.

<%
Sub showform
%>
<form method="post">
Your Name: <input type="text" name="FirstName" /><br />
<input type="submit" name="Submit" value="Submit" />
</form>
<%
End Sub

If Request.Form("Submit") = "" Then
call showform()
Else
If Len(Trim(Request.Form("FirstName")))>0 Then
Response.Write "Your name is " & Trim(Request.Form("FirstName"))
Response.Write "<br />Thanks!!"
Else
Response.Write "You forgot to enter your name"
call showform()
End If
End If
%>
 
M

Mike Brind

Mike Brind said:
Instead of Response.Redirect, use Response.Write to summarise what was
submitted. Yes, it really is that simple.

<%
Sub showform
%>
<form method="post">
Your Name: <input type="text" name="FirstName" /><br />
<input type="submit" name="Submit" value="Submit" />
</form>
<%
End Sub

If Request.Form("Submit") = "" Then
call showform()
Else
If Len(Trim(Request.Form("FirstName")))>0 Then
Response.Write "Your name is " & Trim(Request.Form("FirstName"))
Response.Write "<br />Thanks!!"
Else
Response.Write "You forgot to enter your name"
call showform()
End If
End If
%>

By the way, if you really do want to bounce visitors from one page to the
next, a simple way to expidite Tim's suggestions is as follows:

For Each x in Request.Form
If x <> "Submit" then Session(x) = Request.Form(x)
Next
Response.Redirect "thanks.asp"

You should also be aware that there is no way to guarantee the order in
which the Request.Form collection contents are passed.
 
J

jp2code

Wow! That's something slick I probably would not have thought of!

Thanks Mr. Brind!

"Mike Brind" suggests:
 
J

jp2code

Mr. Slattery:

Thanks! That was even easy to implement! I've already got it working.

A+
 
J

jp2code

So, lots of different tricks for doing the same thing! I like it!

"Jon Paal [MSMD]" pointed out:
 
A

Anthony Jones

jp2code said:
"Mike Brind" suggests:

Wow! That's something slick I probably would not have thought of!

Thanks Mr. Brind!

The problem with this approach is you pollute the Session object, which is
common to all pages for that session, with internal details regarding a
specific page. This is not a good thing. Consider what would happen if
such a form happened use a field name that matches an existing session
variable being used for a complete different purpose.

Use Server.Execute as suggested by Jon Paal, whist there are many solutions
to your requirement Server.Execute is the most appropriate.
 
A

Adrienne Boswell

I've got a form that posts to itself when submitted.

Right now, after the form is submitted, the code checks that all of
its fields are valid, then processes the information. If all goes
well, visitors are then redirected using
Response.Redirect("thanks.asp").

What I'd like to do is replace Response.Redirect("thanks.asp") with
something more like the post that happens on the form so that
"thanks.asp" can display a summary of what was submitted.

Is there a way to do this? Can you call a "post" somehow from Classic
ASP?

I have not spent a lot of time with ASP, so it could be something
simple!

The way I deal with this is this:
1. Start the page off with issubmitted = false
2. Validate and do whatever posting to db I need to do.
3. Change issubmitted to true

HTML is something like:
<% if not issubmitted then%>
<form method="post" action="<%=request.servervariables("Script_name")%>">
<div>
<label for="name" id="name1">Name:</label> <input type="text" name="name"
value="<%=name%>" id="name"><br>
<input type="submit" value="Submit">
</form>
<%else%>
<p>Thank you for submitting the information below:</p>
<dl>
<%For ix = 1 to Request.Form.Count
field = request.form.key(ix)
inputvalue = request.form.item(ix)%>
<dt><%=field%></dt>
<dd><%=inputvalue%></dd>
<%next%>
</dl>
<%end if%>
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top