Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

redirect user based on input with python cgi code

 # Import modules for CGI handling 

    import cgi, cgitb 

    # import pymongo module for connecting to mongodb database
    import pymongo
    from pymongo import MongoClient

    # Create instance of FieldStorage 
    form = cgi.FieldStorage() 

    # creating a mongo client to the running mongod instance
    # The code will connect on the default host and port i.e 'localhost' and '27017'
    client = MongoClient()

    # selecting the database mydb 
    db_mydb = client.mydb

    # selecting the collection user
    collection_user = db_mydb.user

    #print "Content-type:text/html

"

    # Get data from fields
    email = form.getvalue('login-username')
    password  =     form.getvalue('login-password')

    #checking whether user inputs are correct or not
    existence_query = collection_user.find_one({"_id":email,"password":password})


    if(existence_query):
        print "Location:http://localhost/mongo/index.html
"
        print "Content-type:text/html

"
    else:
        print "Location:http://localhost/mongo/index.html
"
        print "Content-type:text/html

"
Comment

PREVIOUS NEXT
Code Example
Python :: python import only one function 
Python :: blue ray size 
Python :: preventing players from changing existing entries in tic tac toe game 
Python :: the best ide for python 
Python :: print chr character in python f string 
Python :: difference between = and is not python 
Python :: double char 
Python :: split column in exact spot python 
Python :: python + credit-german.csv + class 
Python :: sort files in windows order python 
Python :: concat dataset 
Python :: strategy forex with python 
Python :: lines = paths.read().splitlines() 
Python :: tkinter lottery app 
Python :: can data scientists become software developer 
Python :: how to analyze data from dataframe in python 
Python :: varianza en pandas 
Python :: enregistremen en pythin picklr 
Python :: python herencia clases 
Python :: what does bin do in python 
Python :: Errors that you will get during date object in python datetime 
Python :: Python send sms curl 
Python :: python keep program running after crash 
Python :: ridge regression alpha values with cross validation score plot 
Python :: how to open local software using python 
Python :: unittest only run test if other tests passes 
Python :: change legend facecolor 
Python :: pd.generate_date 
Python :: a list of available font in figlet in python 
Python :: insert key in binary tree recursively 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =