hi all
I'm trying to make a simple web using a form and method="POST"
My page works fine in Firefox but fails in IE6.
Can anyone tell me what I'm doing wrong ?
Here is my code
import cgi
import os
import parseFieldStorage
import time
def test():
print 'Content-Type: text/html\n'
print '<h3>You are : ' + user + '</h3>'
print '<h3>And your occupation is : ' + occupation + '</h3>'
form1 = cgi.FieldStorage()
dFs = parseFieldStorage.parse(str(form1))
try:
user = dFs["user"]
occupation = dFs["occupation"]
except:
user = 'user'
occupation = 'occupation'
if user != 'user':
test()
else:
print 'Content-Type: text/html\n\n'
print '<title>POST Test</title>'
print '<form action="http://sew00631:8085/cgi-bin/hej2.py" method="post" enctype="text/plain">'
print 'username:<input type="text" name="user" value="%s">' % user
print 'occupation : <input type="text" name="occupation" value="%s">' % (occupation)
print '<input type="submit" value="go">'
print '</form>'
Another strange this is that it sometimes works (not completely though)in IE. Sometimes the values are updated but the title is set to "About:blank" and the next time I try the page could go blank or the error message "cannot display the page" comes up.
the
dFs = parseFieldStorage.parse(str(form1))
is just my way of getting the values from the fieldstorage because I haven't figured out how to do this when using the method="POST"
her is that code
import string
def parse(fs):
dFs = {}
idx1 = fs.find("'")
if idx1 == -1:
return False
fs2 = fs[idx1+1:]
idx2 = fs2.find("'")
if idx2 == -1:
return False
s = fs[idx1+1:(idx1+idx2+1)]
ls = s.split("\\r\\n")
for item in ls:
try:
ls2 = item.split("=")
dFs[ls2[0]] = ls2[1]
except:
pass
return dFs
I really hope that someone can give me a hint on what I'm doing wrong here
//C