p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   VBScript (http://p2p.wrox.com/forumdisplay.php?f=77)
-   -   Store and display data using asp (http://p2p.wrox.com/showthread.php?t=6376)

erin November 19th, 2003 12:55 PM

Store and display data using asp
Hi All,

How can I store input form data and display in a table using asp page.


pgtips November 19th, 2003 01:24 PM

Depends on the method attribute of the form. If its GET, then you need to look at

to get its value.

If the form is set to POST, the data will be in

To write out data just use

Response.Write Request.Form("whateverTheFieldIsCalled")
As for storing the data, the usual place is a database for which you use ADO.

That's about all I can give you without more detail of what you want to do.


erin November 19th, 2003 01:49 PM

I am using post method and I would like to store and display the data without using database. I was wondering if there was any way that I could display for every input entry from form.


Imar November 19th, 2003 01:56 PM

Yeah, there is a way to do that. The following code will loop through the entire form collection (when the forms' method is Post) and writes out the name and thee value of each HTML control on the form.

Dim anItem
Dim myLoop
With Response
    .Write("<h2>Form Collection</h2>")
    For Each anItem in Request.Form
        For myLoop = 1 to Request.Form(anItem).Count
            .Write("<strong>" & anItem & "</strong> = " & Request.Form(anItem)(myLoop) & "<br />")
End with

You can use more or less the same code for the QueryString collection by changing Form to QueryString.



Imar Spaanjaars
Everyone is unique, except for me.

erin November 19th, 2003 04:30 PM

Hi Imar,
When I submitted the form second time I am overwriting the stored data. I would like to keep both stored data and second input data coming from form.

Is there any way, I can do that...


Imar November 19th, 2003 07:36 PM

Well, if you want to do that, you'll need some way to save state. The Web is stateless by design. this means that as soon as you have requested a page and received the response, the Web server forgets about you.

For static pages, this is not a problem but it is for pages containing forms and other data.

To save state (the information from the page, in your case), you have a couple of options:

1. Use hidden form fields.
Simply append each new value as a hidden form field

2. Use Cookies
Add your form values to the Cookies collection

3. Use a database
You can store each submitted form in the database. Hoop up a User ID to the database record, so you can see what user submitted what data.

4. Use a text file
Same as the database, but uses a text file instead (only applicable for small sites)

5. Use sessions
You can use ASP Session to store information. This solution doesn't scale well (you can't use it in a web farm (multiple Web servers), so it mostly appropriate for small to medium sized Internet and Intranet sites.

What exactly are you trying to accomplish? Can you elaborate a bit about your current ideas. Not every solution is applicable in every scenario.



Imar Spaanjaars
Everyone is unique, except for me.

All times are GMT -4. The time now is 07:15 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.