pymatio 0 Light Poster

I have this python file:

#!/usr/bin/env python
import os
import Cookie
import hashlib
import MySQLdb
import cgi
import cgitb; cgitb.enable()
def showform():
	reshtml = '''Content-Type: text/html\n
	<html>
	<body>
	<a href="register.py">Not a member? </a>
	<form action='login.py' METHOD=post>
	Username: <input type=text name=person value="New User" size = 15><br>
	Password: <input type=password name=pass value="" size=15><br>
	<input type=submit value="Login"></form>
	</body>
	</html>
	'''
	print reshtml

def main():
        conn = MySQLdb.connect(host="localhost", user="root", passwd="cronaldo", db="test")
        reshtml = '''Content-Type: text/html\n
        <html><body>
        %s
        </body>
        </html>
        '''
        cursor = conn.cursor ()
        form = cgi.FieldStorage()
        who = form['person'].value
        passw = form['pass'].value
        m = hashlib.md5()
        m.update(passw)
        cursor.execute("select * from pass where user='%s' and passwrd='%s'" % (who, m.digest()))
        if cursor.rowcount != 1:
                print reshtml % ("Invalid username or password")
        else:
                cookie = Cookie.SimpleCookie()
                string_cookie = os.environ.get('HTTP_COOKIE')
                if not string_cookie:
                        cookie['u'] = who
                else:
                        cookie['u'] = who
                print cookie
                cursor.execute("select name, url from bookmarks where user='%s'" % (who))
                ro = cursor.fetchall()
                st = []
                for row in ro:
                        st.append([row[0], row[1]])
		blah = "<a href='add.py'>add bookmark</a>\n"
		for s in st:
			for a in s:
				blah += a + "\t\t"
			blah += "\n"
                print reshtml % (blah)

form = cgi.FieldStorage()
if not form.has_key('person'):
	showform()
else:
	main()

when I click 'login' it doesn't connect

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.