[Web4lib] collecting form input

Thomas Bennett bennetttm at appstate.edu
Wed Aug 16 08:59:32 EDT 2006


It might help if you could describe what you are working with already such as 
web server, platform and any scripting already supported.  

On the other hand, you can use Zope (http://zope.org) as a receiver of the 
"action" of your form.  On Zope add an odbc database adapter defined to 
connect to the odbc source described below and then create a page (dtml 
method and is the action of your form)  that will call a ZSQL method ( a page 
where you define a simple sql insert statement and list the parameters passed 
from the form).  The rest of the dtml method will be the page the user sees 
after submitting the form.  Zope is OSS and runs on linux, ms windows, mac, 
and others.

Here is a brief synopsis missing css,headers, etc..:
<pre> In case you are using an html email client I hope this works.

form:
<form action=http://zope.server:8080/my_form_result_page>
  name: <input type=text id=name value=" ">
  phone <input type=text id=phone value=" ">
<input type=submit value=send>
</form>



my_form_result_page:
<dtml-call add2db>
<h1>Thank you <dtml-var name>  for submitting the form</h1>
<br />We will call you at <dtml-var phone> soon.


Zsql method named add2db
db adapter: dba2access
params: name phone
sql: insert into my_table values('<dtml-sqlvar name>','<dtml-sqlvar phone>');

database adapter connection parameters:
username=myusername, password=mypassword, port=myodbcport, 
database=mydatabasename

</pre>

I find this is a quick and short method for database interfacing but then I've 
only been working with this method for almost 10 years ;-).

Thomas



From a post on Wed, 26 Jul 2006  on the Zope list:

To connect to an MS Access DB on a windows machine you'll need to set the DB 
up as a system data source on the machine. This is done in the Start menu -> 
Administration -> ODBC datasources.
Add a system data source in there, and browse to your mdb file. Give the data 
source a name of your own choice, and when you go back into the zope manager 
and add the DB  connection you need to write this data source name (DSN) in 
the connection string. After that your ZSQL methods will work perfectly. 


On Tuesday 15 August 2006 21:50, Mark Gilman wrote:
> Hi,
>
> The answer to this is likely obvious, but not to me.  What is the easiest
> way to collect data via a web-based form in such a manner that it can be
> imported into a lightweight database such as Access?  I realize that one
> can use a simple HTML form and then use post or a similar method to email
> the data, but what I'm looking for is a more elegant way to collect
> structured data (i.e. several thousand summer reading program
> registrations) in a manner that obviates the need to rekey it into a
> database.  Preferably this would be a technology that does not rely on a
> lot of fancy server support. I've sort of had one eye on the XForms
> development, but since no browsers supports XForms out of the box, that
> doesn't yet seem the right path to explore.
>
> The basic HTML forms I've used in the past are pretty limited.  Should I be
> exploring multipart/form-data?  What I want to be able to do, I suppose, is
> to be able to aggregate a bunch of strings that are readable by Access as
> records.  They wouldn't have to be very sophisticated.  They are
> essentially just flat files.  I guess we would like to filter or otherwise
> validate certain of the fields.
>
> Regards,
> Mark
>
>
> _______________________________________________
> Web4lib mailing list
> Web4lib at webjunction.org
> http://lists.webjunction.org/web4lib/

-- 
====================================================================
Thomas McMillan Grant Bennett		Appalachian State University
Computer Consultant III			P O Box 32026
University Library				Boone, North Carolina 28608
(828) 262 6587

An important measure of effort in coding is the frequency with which you write 
something that doesn't actually match your mental representation of the 
problem, and have to backtrack on realizing that what you just typed won't 
actually tell the language to do what you're thinking. -Eric Raymond

Library Systems Help Desk: http://linux.library.appstate.edu/help
====================================================================


More information about the Web4lib mailing list