Quoting through a form to get field names and supply values ​​(classic ASP)

When submitting a form, I would like to write down the field names and form values, and I want them to pass without even showing them in the browser (Response.Write makes them visible in the browser). How can I do this, please? I am using this code:

For Each Item In Request.Form fieldName = Item fieldValue = Request.Form(Item) Response.Write(""& fieldName &" = Request.Form("""& fieldName &""")") Next 
+9
source share
3 answers

Your code is essentially correct, so just delete Response.Write and do something else with the fieldName and fieldValue variables that you populate. After you finish working with the data (either insert them into the database or send an email), you can redirect the user to the success / thanks page.

To verify that you are getting the correct input, you can change Response.Write to

 Response.Write fieldName & " = " & fieldValue & "<br>" 


Update

Here you can use the Dictionary object to combine field and field names:

 Dim Item, fieldName, fieldValue Dim a, b, c, d Set d = Server.CreateObject("Scripting.Dictionary") For Each Item In Request.Form fieldName = Item fieldValue = Request.Form(Item) d.Add fieldName, fieldValue Next ' Rest of the code is for going through the Dictionary a = d.Keys ' Field names ' b = d.Items ' Field values ' For c = 0 To d.Count - 1 Response.Write a(c) & " = " & b(c) Response.Write "<br>" Next 
+18
source

This is a very small snippet that I use to display all the fields of the POSTED form.

 <% For x = 1 to Request.Form.Count Response.Write x & ": " _ & Request.Form.Key(x) & "=" & Request.Form.Item(x) & "<BR>" Next %> 
+1
source

Good! But .. if the form is of type enctype = multipart / form-data? Upload.Form.Key exists? thanks

-one
source

All Articles