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

Discussion in 'Python' started by epsilon, Aug 21, 2007.

  1. epsilon

    epsilon Guest

    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"
     
    epsilon, Aug 21, 2007
    #1
    1. Advertisements

  2. Next time try to post the exact error message you get - working
    crystall balls are hard to find nowadays :)
    Ok, it's a syntax error, perhaps you didn't get a useful response from
    the server.
    The error is here:
    That should read:

    print id, "you are logged in with key:", session_key, "\n"
     
    Gabriel Genellina, Aug 21, 2007
    #2
    1. Advertisements

  3. epsilon

    epsilon Guest

    Gabriel,

    Thanks a bunch for your time! That took care of it.

    Christopher
     
    epsilon, Aug 21, 2007
    #3
  4. epsilon

    Steve Holden Guest

    Gabriel Genellina wrote:

    [...]working crystall balls are hard to find nowadays :)

    Well, judging by the OP's response you appear to be in possession of a
    pair :)

    regards
    Steve
    --
    Steve Holden +1 571 484 6266 +1 800 494 3119
    Holden Web LLC/Ltd http://www.holdenweb.com
    Skype: holdenweb http://del.icio.us/steve.holden
    --------------- Asciimercial ------------------
    Get on the web: Blog, lens and tag the Internet
    Many services currently offer free registration
    ----------- Thank You for Reading -------------
     
    Steve Holden, Aug 22, 2007
    #4
  5. Great-grandmother's legacy, and not for sale!
     
    Gabriel Genellina, Aug 22, 2007
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.