Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #login
- @app.route('/login', methods=('GET', 'POST'))
- def login():
- if request.method == 'POST':
- email = request.form['email']
- password = request.form['password']
- #cek data username
- #cursor = mysql.connection.cursor()
- cursor = db.cursor()
- cursor.execute('SELECT * FROM tb_users WHERE email=%s',(email, ))
- akun = cursor.fetchone()
- if akun is None:
- flash('Login Gagal, Cek Username Anda','danger')
- elif not check_password_hash(akun[3], password):
- flash('Login gagal, Cek Password Anda', 'danger')
- else:
- session['loggedin'] = True
- session['username'] = akun[1]
- session['level'] = akun[4]
- return redirect(url_for('index'))
- return render_template('login.html')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement