Transfer data from webpage form to database

Pete..... helten0007 at
Wed Nov 24 01:03:13 CET 2004

First thanks for all your friendly input and for looking at this once 

I think I made some progress, but its still not working, so I must still do 
something wrong.
Here is how far I have come.

I made an insertintotable script, that I want to run every time a person 
presses "The submit button on my webpage" It goes like this:

from pyPgSQL import PgSQL
import cgi
import cgitb

form = cgi.FieldStorage()

connect = PgSQL.connect(user="user", password="password", host="host", 
cur = connect.cursor()
cur.execute('''INSERT INTO persons (name, surname, username, password) 
(VALUES(%s,%s, %s, %s)''')
%(form[name].value, form[surname].value, form[username].value, 
My question is, do I need more code to tell the program that I want to 
transfer the user input ( on my webpage ) to my postgresql database.
The code from my webpage is:


from pyPgSQL import PgSQL
import cgi
import cgitb

print '''



<title> Adminperson  </title>


<body bgcolor="#0479ff">

<h1><p align="center">Insert Person</h1></p>


<form action="" method="get">
    <p>Name:<br><input type="text" name="name"></p>
    <p>Surname:<br><input type="text" name="surnavn"></p>
    <p>Username:<br><input type="text" name="usernavn"></p>
    <p>Password:<br><input type="text" name="password"></p>
    <p><input type="submit" value="Submit"></p>
</body> </html>'''
And once again thanks... 

More information about the Python-list mailing list