Advertisement
Guest User

Untitled

a guest
Mar 14th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. @app.route('/validateLogin',methods=['POST'])
  2. def validateLogin():
  3. try:
  4. _username = request.form['inputEmail']
  5. _password = request.form['inputPassword']
  6.  
  7.  
  8.  
  9. # connect to mysql
  10.  
  11. con = mysql.connect()
  12. cursor = con.cursor()
  13. cursor.callproc('sp_validateLogin',(_username,))
  14. data = cursor.fetchall()
  15.  
  16.  
  17. if len(data) > 0:
  18. if str(data[0][5]) == _password:
  19. session['user'] = data[0][1]
  20. return redirect('/userHome')
  21. else:
  22. return render_template('error.html',error = 'Wrong password')
  23. else:
  24. return render_template('error.html',error = 'Wrong username.')
  25.  
  26.  
  27. except Exception as e:
  28. return render_template('error.html',error = str(e))
  29.  
  30. finally:
  31. if cursor:
  32. cursor.close()
  33. if con:
  34. con.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement