hi folks,
I'm trying to create a simple log in. And here what i got so far:
when i put this script on my site, it shows the log in form(user and password), but when i put user name and password in and click button "Log in" then it does not work.
I don't know what i have done wrong. Any idea ? thanks
I'm trying to create a simple log in. And here what i got so far:
Code:
def check_login():
user=form.getfirst("username")
password=form.getfirst("password")
pwd = { 'user': 'password',
'game': 'blivit',
}
if form.has.key(user) and form.has.key(password):
print "You are now logged in"
else:
form1()
print "Invalid username or password"
def form1():
print """
<FORM ACTION="assign5.cgi" METHOD="POST">
<P><FONT SIZE="5" COLOR="#990000">Login</FONT><BR>
<TABLE BORDER="0" WIDTH="271">
<TR>
<TD WIDTH="48%">
<P ALIGN="RIGHT">Username:
</TD>
<TD WIDTH="1%">Â </TD>
<TD WIDTH="51%"><INPUT TYPE="TEXT" NAME="username" SIZE="12"></TD>
</TR>
<TR>
<TD WIDTH="48%">
<P ALIGN="RIGHT">Password:
</TD>
<TD WIDTH="1%">Â </TD>
<TD WIDTH="51%"><INPUT TYPE="PASSWORD" NAME="password" SIZE="12"></TD>
</TR>
<TR>
<TD WIDTH="48%">Â </TD>
<TD WIDTH="1%">Â </TD>
<TD WIDTH="51%"><INPUT TYPE="SUBMIT" NAME="submit" VALUE="Login"><INPUT TYPE="RESET" NAME="Reset" VALUE="Clear"></TD>
</TR>
</TABLE>
</FORM>"""
form1()
check_login()
form = cgi.FieldStorage()
print"</BODY></HTML>"
when i put this script on my site, it shows the log in form(user and password), but when i put user name and password in and click button "Log in" then it does not work.
I don't know what i have done wrong. Any idea ? thanks