Hi, im have just started programming python with cgi and i will try to use dbm as a db to practise<br>But i cant figure out how to diplay all the data from it..<br><br>this is the code im using<br><br>/////////////<br>#!/usr/bin/python
<br><br>print "Content-Type: text/html\n\n"<br><br>import cgi, dbm<br><br>def startpage(title):<br> print '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>"><br> <html xmlns="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>"><br> <head><br> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<br> <title>''',title,'''</title><br> </head><br> <body>'''<br> <br>def endpage():<br> print """</body><br> </html>"""<br><br>def main():
<br> form = cgi.FieldStorage()<br> if(form.has_key("name") and form["name"].value != ""):<br> try:<br> db = dbm.open("dbm", "c")<br> db["name"] = form["name"].value
<br> db.close()<br> print "Info saved. Now, <a href='?read=true'>read</a> it?"<br> except:<br> print cgi.print_exceptions()<br> elif(form.has_key("read") and form["read"].value == "true"):
<br> try:<br> db = dbm.open("dbm", "r")<br> for key in db.keys():<br> print key<br> except:<br> print cgi.print_exceptions()<br> else:<br>
print """<form action="test.py" method="post"><br> <input name="name" type="text" id="name" /><br> <input type="submit" name="Submit" value="Send my name" />
<br> </form>"""<br><br>startpage("Test Page")<br>main()<br>endpage()<br>/////////////<br>Thanks in advance<br clear="all"><br>-- <br>Best Regards.<br>fedekiller