Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check form submission ASP classic

I'm setting up a form in ASP classic and it will reload after submission (action self)

But this time it shows results of previous submissions, so how can I check that a POST submission has been made?

Like in PHP:

if($_POST['submit']) {
  show results...
}
like image 968
Th3Alchemist Avatar asked May 20 '12 15:05

Th3Alchemist


People also ask

Does Microsoft still support Classic ASP?

The use of ASP pages with Microsoft Internet Information Services (IIS) is currently supported in all supported versions of IIS. IIS is included in Windows operating systems. Therefore, both ASP and IIS support lifetimes are tied to the support lifecycle of the host operating system.

Is Classic ASP deprecated?

Classic ASP is still supported and will be all the time that it is included in IIS, which is a component of Windows Server.


1 Answers

You have several options:

Method 1 - Check the request method:

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
    'Show Results...
End If

Method 2 - add a hidden field to your form with a value then check if that value has been posted:

If Request.form("HiddenValue") = "1" Then
    'Show Results...
End If

Method 3 - Check if the request.form collection contains items:

If Request.Form.Count > 0 Then
    'Show Results...
End If

Method 4 - Post to a querystring (i.e. set action of <form> to ?post=yes)

If Request.QueryString("post") = "yes" Then
    'Show Results...
End If

Which one to pick?

My preferred option is method 4 – as it’s easily visible in the address bar as to what’s going on – if for some reason I want to avoid presenting this level of detail in the url, I tend to use option 3 as it’s easy to implement, requires no changes on the source forms & is reliable. As for the other two methods:

  • Method 1 – I tend to avoid relying on server variables if I don’t have 100% control over the server – no real justification for that, just a general habit I tend to work with.
  • Method 2 – You could substitute a hidden field for another field that will always contain a value.
like image 67
HeavenCore Avatar answered Oct 03 '22 22:10

HeavenCore