[Tutor] CGI problem.
Mark Kels
mark.kels at gmail.com
Fri Nov 5 23:00:04 CET 2004
Hi,
I made a CGI script, that checks if the user entered a vaild pass
(that should be in "pass.txt").
Here is what I did:
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 a==form.getfirst("pass"):
print "OK, come in."
else:
print "Wrong password, try again! "
printhtml()
checkpass()
x.close()
The problem is that when the page opens it writes "Wrong password, try
again! ", and the user dont get a chance to write the password first.
what can I do so that it will work like it shold (first get the
password, and only then say if its good or not).
I know (or at least hope) that there is a very simple solution for
this problem, but cant find it by myself...
Thanks!!
More information about the Tutor
mailing list