Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8876439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:12:49+00:00 2026-06-14T19:12:49+00:00

In my login method I’m trying to check wether the password in the database

  • 0

In my login method I’m trying to check wether the password in the database corresponds to the password submitted by the user. I use this code:

@app.route('/login', methods=['GET', 'POST'])
def login():
error = None
db = get_db()
if request.method == 'POST':
    cur = db.execute('select password from users where username = ?', (request.form['username'], ))
    password = cur.fetchone()
    print password
    print request.form['password']
    if request.form['password'] != password:
        error = 'Invalid username/password combination'
    else:
        session['logged_in'] = True
        flash('You were logged in')
        return redirect(url_for('show_entries'))
return render_template('login.html', error=error)

For example when the password is default, this what the print commands show me:

print password : (u'default',)
print request.form['password'] : default

So they are indeed not equal. Does anybody knows how to fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:12:51+00:00Added an answer on June 14, 2026 at 7:12 pm

    Each row returned by the database is a tuple of columns. You retrieved one row (.fetchone()) and that row is a tuple with one element (you selected only the password column). Simply take it out from the tuple using it’s index:

    password = cur.fetchone()[0]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to change this method to check the login and password and after it
In LogIn method I have: FormsAuthentication.SetAuthCookie(model.User, false); and to get name of this user
I have a login method that connects to a server to check the user
I have the following code: [self.view bringSubviewToFront:loggingIn]; [self loginWithUsername:user Password:pw]; This is inside an
I have a controller user with a method login For some reason, when I
I have written a login form, in this I have used, form and method
I am trying to implement login method with JSF, EJB and JPA. My current
This is my jsf code :- <h:commandButton id=cmdLogin value=Login actionListener=#{indexBean.login}> <f:ajax execute=@form render=@all />
Controller: class SessionsController < ApplicationController layout 'login' def create user = login(params[:username], params[:password]) if
The JS API's FB.login method returns a response with a dictionary of user info,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.