Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
697 B
1
Indexable
Never
def check_credentials(username, password):
    try:
        connection = mysql.connector.connect(
            host="localhost",
            user="root",
            password="12345",
            database="pfe"
        )

        cursor = connection.cursor()
        query = "SELECT * FROM users WHERE username = %s AND password = %s"
        cursor.execute(query, (username, password))
        result = cursor.fetchone()

        if result:
            return True  # Credentials are valid
        else:
            return False  # Credentials are invalid

    except mysql.connector.Error as error:
        print("Error while connecting to MySQL", error)
        return False
Leave a Comment