Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from mod_python import apache
- import md5
- import string
- import base64
- import MySQLdb
- def get_info(req):
- info = req.form
- userName = info['uname_val']
- userPass = info['uspass_val']
- db = MySQLdb.connect(host="localhost", user="root", passwd="achayan", db="myDiaryDB")
- cursor = db.cursor()
- userCheck = ("""SELECT username FROM userTB WHERE username = '%s' """)%str(userName)
- getUserStat = str(cursor.execute(userCheck))
- sqlErrorCheck = 0
- if getUserStat == "0":
- pythonOutPut = "%s not exists in our database "%userName
- sqlErrorCheck = 1
- else:
- userPassCheck = ("""SELECT passwd FROM userTB WHERE username = '%s' """)%str(userName)
- cursor.execute(userPassCheck)
- passData = cursor.fetchall()
- getUserPassStat = passData[0][0]
- getUserPassStat=base64.b64decode(getUserPassStat)
- if getUserPassStat == userPass:
- userDataCheck = ("""SELECT * FROM userTB WHERE username = '%s' """)%str(userName)
- cursor.execute(userPassCheck)
- userpassData = cursor.fetchall()
- pythonOutPut = "Login attempt was successfull %s "%userpassData
- else:
- pythonOutPut = "Login attempt was not successfull,check your password %s "%getUserPassStat
- return """
- <html><head>
- <title>POST method with mod_python</title>
- </head>
- <body>
- %s <br>
- </body>
- </html>
- """ %(pythonOutPut)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement