Click here for a live demonstration

<%@ Language=VBScript %>
<%
' ASP Generic form processor
' Ben Meghreblian 4th June 2006
' benmeg at benmeg dot com / http://benmeg.com/code/asp/generic.form.processor.html
'
' This script takes the output of an HTML form, with either a POST or GET method
' and outputs all the variables sent to it.
'
' Perfect for the basis of a form-mailer or questionnaire engine

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then %>

Form method: <b>POST</b><br><br>

<% For i = 1 to Request.Form.Count %>

 <b><%=Request.Form.Key(i)%>:</b>&nbsp;<%=Request.Form.Item(i)%><br>

<% Next
ElseIf Request.ServerVariables("REQUEST_METHOD") = "GET" Then %>

Form method: <b>GET</b><br><br>

<% For each qryItem in Request.QueryString %>

	<b><%= qryItem %>:</b>&nbsp;<%= Request.QueryString(qryItem) %><br>

<% Next
Else %>
No form method specified
<% End If %>

Demo

Both forms send their data to the same page

 

Request method is POST

Name

Phrase

Find this useful?

Other comments

Favourite words


Request method is GET (via URL Querystring)

First name

Password

Salary

Best time to call?