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

ok

I can now get the parameter values in a more correct way I think (?)
it had to do with the enctype = "text/plain"

I now retrieve the values like this

user = form["user"]
all variables gets updated correct

my problem seems to be when I want to display the result page i.e the function test
ofcourse this works in mozilla but still not in IE

As you all understand I very new to this so if you could point me in any possible direction I would be grateful.

doesn't the server send the correct headers to the client after processing the form ??
(guessing now, pretty frustrated after a couple of days struggling with this probably easy thing)

hi,

It happens the same to me.
With FF it works perfect,
but with MSIE the post is lost. I review the server logs and there isn't any error.

Hope you found the solution.

Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.