VB icon

VarsFromForm

Email
Submitted on: 1/5/2015 8:38:00 AM
By: Dean Kroon (from psc cd)  
Level: Intermediate
User Rating: By 8 Users
Compatibility: ASP (Active Server Pages)
Views: 687
 
     This subroutine creates a variable (on the fly) for each form item found on Request.Forms or Request.QueryString collections. The variable is given the same name as the form items name. It was built to duplicate some of PHPs built in functionality.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: VarsFromForm
' Description:This subroutine creates a variable (on the fly) for each form item found on Request.Forms or Request.QueryString collections. The variable is given the same name as the form items name. It was built to duplicate some of PHPs built in functionality. 
' By: Dean Kroon (from psc cd)
'
' Assumes:
Ex.
' this form lives in some asp or html page
<form method="post" action="doit.asp">
 <input type="text" name="name">
 <input type="text" name="Address1">
 <input type="text" name="Address2">
</form>
' the user enters:
 Dean Kroon
 421 Blue Earth St
 PO Box 123
' this code lives in doit.asp
<%
 Call VarsFromForm
 Response.write name & "<br>" & address1 & ", " & address2
%>
' The output looks like
 Dean Kroon
 421 Blue Earth St, PO Box 123
'**************************************

public sub VarsFromForm
	for each item in request.form
		execute(item & "=""" & Replace(request.form(item), Chr(34), Chr(34) & Chr(34)) & """")
	next
	for each item in request.QueryString
		execute(item & "=""" & Replace(request.QueryString(item), Chr(34), Chr(34) & Chr(34)) & """")
	next
end sub


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.