samedi 25 juillet 2020

TypeError: list indices must be integers or slices, not str , dont know what im doing wrong

Allright, I want to compare 2 password but I keep getting this error. The code I am running is the code below:

(@app and def are here, then session clear, followed by the code below)

    if request.method == 'POST':
        email = request.form['email']
        hash = generate_password_hash(request.form.get("password"))

        user = db.execute("SELECT * FROM users WHERE email=%s",(email,))

        if len(user) > 0:
            if check_password_hash(user["password"], request.form.get("password")):
                session['name'] = user['name']
                session['email'] = user['email']
                return render_template("home.html")
            else:
                return "Error password and email not match"
        else:
            return "Error user not found"



Aucun commentaire:

Enregistrer un commentaire