[Tutor] CGI problem.
Chad Crabtree
flaxeater at yahoo.com
Sat Nov 6 04:08:36 CET 2004
Ok I don't quite have all the information to give you a definitive
answer but I believe this is your trouble. You are loading the file
from the cgi script which is fine however you still check for the
password every time whether or not it's the first time to run. so
you
need to check to see if it's empty or if it exists.
Mark Kels wrote:
>import cgi
>
>import cgitb; cgitb.enable()
>
>form = cgi.FieldStorage()
>
>x=open("pass.txt","r")
>
>form.getfirst("pass")
>
>print "Content-type: text/html\n\n"
>
>def printhtml():
>
> print """
>
> <html><body>
>
> <form><input name="pass" type="text"></form>
>
> """
>
>def checkpass():
>
> a=x.readline()
>
>
>
if form.has_key("pass"):
> if a==form.getfirst("pass"):
>
> print "OK, come in."
>
> else:
>
> print "Wrong password, try again! "
>
>
>
>
>
>printhtml()
>
>checkpass()
>
>x.close()
>
>
I think adding that line should make this script work. Or you could
put
than line right before the checkpass statement like
if form.has_key("pass"):
checkpass()
Good luck
__________________________________
Do you Yahoo!?
Check out the new Yahoo! Front Page.
www.yahoo.com
More information about the Tutor
mailing list