Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. from mod_python import apache
  2. import md5
  3. import string
  4. import base64
  5. import MySQLdb
  6. def get_info(req):
  7.     info = req.form
  8.     userName = info['uname_val']
  9.     userPass = info['uspass_val']
  10.     db = MySQLdb.connect(host="localhost", user="root", passwd="achayan", db="myDiaryDB")
  11.     cursor = db.cursor()
  12.     userCheck = ("""SELECT username FROM userTB  WHERE username = '%s' """)%str(userName)
  13.     getUserStat = str(cursor.execute(userCheck))
  14.     sqlErrorCheck = 0
  15.     if getUserStat == "0":
  16.         pythonOutPut = "%s not exists in our database "%userName
  17.         sqlErrorCheck = 1
  18.     else:
  19.         userPassCheck = ("""SELECT passwd FROM userTB  WHERE username = '%s' """)%str(userName)
  20.         cursor.execute(userPassCheck)
  21.         passData = cursor.fetchall()
  22.         getUserPassStat = passData[0][0]
  23.         getUserPassStat=base64.b64decode(getUserPassStat)
  24.         if getUserPassStat == userPass:
  25.             userDataCheck = ("""SELECT * FROM userTB  WHERE username = '%s' """)%str(userName)
  26.             cursor.execute(userPassCheck)
  27.             userpassData = cursor.fetchall()
  28.             pythonOutPut = "Login attempt was successfull %s "%userpassData
  29.         else:
  30.             pythonOutPut = "Login attempt was not successfull,check your password %s "%getUserPassStat
  31.  
  32.     return """
  33.     <html><head>
  34. <title>POST method with mod_python</title>
  35. </head>
  36. <body>
  37. %s <br>
  38. </body>
  39. </html>
  40. """ %(pythonOutPut)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement