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 &quot;Content-Type: text/html\n\n&quot;<br><br>import cgi, dbm<br><br>def startpage(title):<br>&nbsp;&nbsp;&nbsp; print '''&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>&quot;&gt;<br>&nbsp;&nbsp;&nbsp; &lt;html xmlns=&quot;<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>&quot;&gt;<br>&nbsp;&nbsp;&nbsp; &lt;head&gt;<br>&nbsp;&nbsp;&nbsp; &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; /&gt;
<br>&nbsp;&nbsp;&nbsp; &lt;title&gt;''',title,'''&lt;/title&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/head&gt;<br>&nbsp;&nbsp;&nbsp; &lt;body&gt;'''<br>&nbsp;&nbsp;&nbsp; <br>def endpage():<br>&nbsp;&nbsp;&nbsp; print &quot;&quot;&quot;&lt;/body&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/html&gt;&quot;&quot;&quot;<br><br>def main():
<br>&nbsp;&nbsp;&nbsp; form = cgi.FieldStorage()<br>&nbsp;&nbsp;&nbsp; if(form.has_key(&quot;name&quot;) and form[&quot;name&quot;].value != &quot;&quot;):<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; try:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; db = dbm.open(&quot;dbm&quot;, &quot;c&quot;)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; db[&quot;name&quot;] = form[&quot;name&quot;].value
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; db.close()<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print &quot;Info saved. Now, &lt;a href='?read=true'&gt;read&lt;/a&gt; it?&quot;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; except:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print cgi.print_exceptions()<br>&nbsp;&nbsp;&nbsp; elif(form.has_key(&quot;read&quot;) and form[&quot;read&quot;].value == &quot;true&quot;):
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; try:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; db = dbm.open(&quot;dbm&quot;, &quot;r&quot;)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for key in db.keys():<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print key<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; except:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print cgi.print_exceptions()<br>&nbsp;&nbsp;&nbsp; else:<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print &quot;&quot;&quot;&lt;form action=&quot;test.py&quot; method=&quot;post&quot;&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input name=&quot;name&quot; type=&quot;text&quot; id=&quot;name&quot; /&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Send my name&quot; /&gt;
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/form&gt;&quot;&quot;&quot;<br><br>startpage(&quot;Test Page&quot;)<br>main()<br>endpage()<br>/////////////<br>Thanks in advance<br clear="all"><br>-- <br>Best Regards.<br>fedekiller