Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import cgi, cgitb
- import mysql.connector
- import requests
- import sys
- cgitb.enable()
- def login():
- flag= False
- cnx = mysql.connector.connect(user='root', passwd='root',
- host='localhost',
- database='BLOG')
- form = cgi.FieldStorage()
- user_name = form.getvalue('user_name')
- password = form.getvalue('password')
- check_user = "select user_name,password from users where user_name = 'hussain8' and password='hussain008'"
- data_user = (user_name,password)
- cur = cnx.cursor()
- cur.execute(check_user)
- rows = cur.fetchall()
- if isEmpty(rows):
- #print (cur.fetchall())
- with requests.session(user_name,password) as s:
- payload = {
- 'username': user_name,
- 'pass': password
- }
- url='http://localhost/login.py'
- s.get(url)
- s.post(url, data=payload)
- print 'Location:/test1.py'
- print "Content-type: text/html"
- print
- else:
- print 'Location:/loginError.py'
- print "Content-type: text/html"
- print
- def isEmpty(dictionary):
- for element in dictionary:
- if element:
- return True
- return False
- login()
- and the file where i want to use:
- #!/usr/bin/env python
- import requests
- import json
- s=requests.session()
- req=s.get('http://localhost/login.py')
- print(req.json)
- print("Content-Type: text/html;charset=utf-8")
- print""
- print "Content-type:text/htmlrnrn"
- print""
- print """<html>
- <head></head>
- <body>
- <h1>user name = %print(name)%</h1>
- <h1>user name = %print(password)%</h1>
- </body>
- <script src="js/jquery-1.11.3.min.js"></script>
- <script src="js/bootstrap.min.js"></script>
- </html>
- """
Add Comment
Please, Sign In to add comment