Trouble with CGI code from Code Example 7.3 of the "Python Interactive CGI Tutorial"

epsilon cesmiga at gmail.com
Tue Aug 21 16:14:45 CEST 2007


Hey gang!

I'm having trouble with this script from a CGI lesson I'm working and
I can't seem to figure it out.  I was wondering if someone could tell
me what is wrong.  I've spent several hours trying to debug, but no
success.  Any help would be appreciated.

Thank you,
Christopher

+++++

Python Interactive CGI Tutorial - Code Example 7.3
        http://www.cs.virginia.edu/~lab2q/lesson_7/

# Define function display_page.
def display_page(result, id, session_key = 0):
    print "<HTML>\n"
    print "<HEAD>\n"
    print "\t<TITLE>Info Form</TITLE>\n"
    print "</HEAD>\n"
    print "<BODY BGCOLOR = white>\n"
    if (result == "passed"):
        if (session_key == 0):
            session_key = create_session(id)
            print id, , you are logged in with key:", session_key,
"\n"
            print "\t\t<FORM METHOD = post ACTION = \
            \"example_7.3.cgi\">\n"
            print "\t\t<INPUT TYPE = \"hidden\" NAME = \
            \"session_key\" VALUE =\", session_key, ">\n"
            print "\t\t<INPUT TYPE = \"submit\" \
            VALUE = \"Stay Logged In.\"></FORM>\n"
            print "\t\t<FORM METHOD = post ACTION = \
            \"example_7.3.cgi\">\n"
            print "\t\t<INPUT TYPE = \"hidden\" NAME = \
            \"session_key\" VALUE =", session_key, ">\n"
            print "\t\t<INPUT TYPE = \"hidden\" NAME =\
            \"logout\" VALUE = \"logout\" >\n"
            print "\t\t<INPUT TYPE = \"submit\" \
            VALUE = \"Logout.\"></FORM>\n"
        else:
            print "You entered the incorrect combo.\n"
            print "</BODY>\n"
            print "</HTML>\n"




More information about the Python-list mailing list