Upon pressing the sign in button it prints out the whole error.html file to the web console rather than redirecting to userhome.html, which bit is going wrong, cheers! Code for everything is below...
Python:
@app.route('/ValidateLogin',methods=['POST'])
def ValidateLogin():
try:
_username = request.form['username']
_password = request.form['password']
#connection to MySQL
cur = mysql.connection.cursor()
cur.callproc('sp_validateLogin', (_username,))
data = cur.fetchall()
if len(data) > 0:
if check_password_hash(str(data[0][3]), _password):
session['user'] = data[0][0]
return redirect('/UserHome')
else:
return render_template('error.html', error = 'Wrong Email Address or Password')
else:
return render_template('error.html', error = "Invalid Email Address or Password")
except Exception as e:
return render_template('error.html', error = str(e))
finally:
cur.close()
JS:
$(function() {
$('#btnSignIn').click(function() {
$.ajax({
url: '/ValidateLogin',
data: $('form').serialize(),
type: 'POST',
success: function(response) {
console.log(response);
},
error: function(error) {
console.log(error);
}
});
});
});