I am building a user flask application using MySQL and in the user login code i get the error TypeError: string indices must be integers every time.
@app.route('/signin',methods=['GET','POST'])
def signin():
if request.method == 'POST':
email = request.method['email']
password_entered = request.method['password']
cur = mysql.connection.cursor()
user = cur.execute("SELECT * FROM users WHERE email = %s",(email))
if user > 0:
data = cur.fetchone()
real_password = data['password']
name = data['name']
email = data['email']
if pbkdf2_sha256.verify(password_entered,real_password):
session['logged_in'] = True
session['name'] = name
session['email'] = email
flash('Sign In Successful!',category='info')
return redirect(url_for('index'))
else:
flash('Details Incorrect!Please try again.',category='error')
return render_template('signin.html')
else:
flash('User does not exist!Please Register.',category='error')
return redirect(url_for('signup'))
return render_template('signin.html')
Python shows that the error is from the line email = request.method['email']
. Please assist.