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

E

epsilon

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"
 
G

Gabriel Genellina

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.

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:
if (session_key == 0):
session_key = create_session(id)
print id, , you are logged in with key:", session_key,

That should read:

print id, "you are logged in with key:", session_key, "\n"
 
S

Steve Holden

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 -------------
 
G

Gabriel Genellina

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 :)

Great-grandmother's legacy, and not for sale!
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top