And im stucked with the login system.
GOD! I hate being a noob!
Well, this is the login page
################################
#!/usr/bin/python
import cgi, dbm, string, Cookie
import config
request = cgi.FieldStorage()
def loginform():
print '''<form action="" method="post">
<table border="0">
<tr>
<td>Username</td>
<td><input name="user" type="text" id="user" /></td>
</tr>
<tr>
<td>Password</td>
<td><input name="pass" type="text" id="pass" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Login" /></td>
</tr>
</table>
</form>'''
def main():
C = Cookie.SimpleCookie()
if(C.has_key("admin_user") and C.has_key("admin_pass")):
admin = config.getadmin()
if(C["admin_user"].value == admin[0] and C["admin_pass"].value == admin[1]):
config.makepage("You are already logged!")
else:
config.makepage("Wrong cookies...")
elif(request.has_key("Submit")):
admin = config.getadmin()
username = config.clean(request["user"].value)
password = config.clean(request["pass"].value)
if(username == admin[0] and password == admin[1]):
C["admin_user"] = username
C["admin_pass"] = password
print C
print "Content-Type: text/html\n\n"
config.startpage()
print "Bienvenido",username,'!'
config.endpage ()
else:
print "Content-Type: text/html\n\n"
config.startpage()
print "Incorrect username and password combination"
config.endpage ()
else:
print "Content-Type: text/html\n\n"
config.startpage()
loginform()
config.endpage()
main()
################################
That seems to work..but i cant get the cookies, i tried making this to get them but i have a 500 error -.- i hate it so much
#################################
#!/usr/bin/python
try:
import Cookie
print "Content-Type: text/html\n\n"
C = Cookie.SimpleCookie()
print C.["admin_user"].value
except:
cgi.print_exception()
###################################
i tried that in different ways but i cant get it to work
Help please :(
--
Best Regards.
fedekiller
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor