User authentication

import streamlit as st
import pymysql
import pandas as pd
import webbrowser as web
username=st.text_input(“Please input your username:”)
pwd=st.text_input(“Please input your password”,type=‘password’)
db = pymysql.connect(host=“localhost”, user=“root”, password=“abcde”, database=“python”, charset=“utf8”)
sql=“select * from pwd”
cursor = db.cursor()
cursor.execute(sql)
db.commit()
df=pd.read_sql(sql,con=db)
if username=="":
st.info(“You do not have input user name yet”)
elif pwd=="":
st.info(“You do not have input password yet”)
else:
if username in df.values and pwd in df.values:
st.success(“Welcome back!”)
web.open(“https://www.baidu.com/”)
else:
st.warning(“Sorry, you can not login in, please check your user name or password.”)

1 Like