1

I got some sort of error when i tried to login with an account that has been registered in my database. I have only done the register function. I can register and automatically login to the website however, when i tried to log out and login with the same account, i got the error. Could it be because i changed some stuff in the database and had to reset the whole phpliteadmin database? Or what is it? This is my register code in case it helps

if request.method == "POST":
    if not request.form.get("username"):
        return apology("Missing Username!")
    elif not request.form.get("password"):
        return apology("Missing Password!")

    if not request.form.get("password") == request.form.get("Confirm password"):
        return apology("Password and Password Confirmation are not consistent!")

    hash = pwd_context.hash(request.form.get("password"))
    result = db.execute("INSERT INTO users(username, hash) VALUES(:username, :hash)",username=request.form.get("username"), hash=hash)
    if not result:
        return apology("Username exists already")

    session["user_id"] = result
    return redirect("/")

return render_template("register.html")

You must log in to answer this question.

Browse other questions tagged .