Python Forum
Problem applying conditions against results back from a database
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem applying conditions against results back from a database
#32
Got it! Thanks, man! I had to add the return render_template line too but now it works. Appreciate the help now I get what I was doing wrong.

@app.route("/login", methods=["GET","POST"])
def login():
    password = request.form.get("password")
    username = request.form.get("username")
    usernamedata = db.execute("SELECT username FROM users WHERE username=:username", {"username":username}).fetchone()
    passworddata = db.execute("SELECT password FROM users WHERE username=:username", {"username":username}).fetchone()
    
    if not usernamedata:
        print('invalid username')
        return render_template("login.html")
    elif username is not None and usernamedata[0] == username and passworddata[0] == password:
        print("welcome")
        return render_template("welcome.html")
    elif username is not None and (usernamedata[0] != username or passworddata[0] != password):
        print("no match")
        return render_template("login.html")
    else:
        print("empty")
        return render_template("login.html")
Reply


Messages In This Thread
RE: Problem comparing two values - by card51shor - Jun-12-2020, 02:59 AM
RE: Problem comparing two values - by ndc85430 - Jun-12-2020, 03:48 AM
RE: Problem comparing two values - by card51shor - Jun-12-2020, 04:01 AM
RE: Problem comparing two values - by ndc85430 - Jun-12-2020, 04:09 AM
RE: Problem comparing two values - by card51shor - Jun-12-2020, 05:03 AM
RE: Problem comparing two values - by ndc85430 - Jun-12-2020, 05:05 AM
RE: Problem comparing two values - by card51shor - Jun-12-2020, 05:07 AM
RE: Problem comparing two values - by ndc85430 - Jun-12-2020, 05:09 AM
RE: Problem comparing two values - by card51shor - Jun-12-2020, 05:10 AM
RE: Problem comparing two values - by ndc85430 - Jun-12-2020, 05:12 AM
RE: Problem comparing two values - by card51shor - Jun-12-2020, 05:14 AM
RE: Problem comparing two values - by ndc85430 - Jun-12-2020, 05:17 AM
RE: Problem comparing two values - by card51shor - Jun-12-2020, 05:24 AM
RE: Problem comparing two values - by ndc85430 - Jun-12-2020, 05:27 AM
RE: Problem comparing two values - by card51shor - Jun-12-2020, 05:29 AM
RE: Problem comparing two values - by ndc85430 - Jun-12-2020, 05:33 AM
RE: Problem comparing two values - by card51shor - Jun-12-2020, 05:35 AM
RE: Problem comparing two values - by ndc85430 - Jun-12-2020, 05:41 AM
RE: Problem comparing two values - by card51shor - Jun-12-2020, 06:04 AM
RE: Problem comparing two values - by card51shor - Jun-12-2020, 11:54 PM
RE: Problem comparing two values - by pyzyx3qwerty - Jun-13-2020, 05:12 AM
RE: Problem comparing two values - by Yoriz - Jun-13-2020, 08:51 AM
RE: Problem comparing two values - by card51shor - Jun-13-2020, 05:21 AM
RE: Problem comparing two values - by pyzyx3qwerty - Jun-13-2020, 07:56 AM
RE: Problem comparing two values - by card51shor - Jun-13-2020, 04:36 PM
RE: Problem comparing two values - by Yoriz - Jun-13-2020, 05:00 PM
RE: Problem comparing two values - by card51shor - Jun-13-2020, 05:13 PM
RE: Problem comparing two values - by Yoriz - Jun-13-2020, 05:19 PM
RE: Problem comparing two values - by card51shor - Jun-13-2020, 05:22 PM
RE: Problem applying conditions against results back from a database - by card51shor - Jun-13-2020, 05:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  applying total in a loop to a list JustinxFFx 1 2,216 Feb-11-2018, 03:14 AM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020