def editinfo(): """ 修改个人信息 :return: Userinfo.html """ userid = session['userid'] try: if request.method == 'POST': password = request.form['password'] age = request.form['age'] try: sql = "UPDATE User SET Location='{}',Age= '{}' WHERE UserID='{}'".format( password, age, userid) mysql.exe(sql) logger.info( "UPDATE userinfo --> username:{},password:{},age:{} ". format(userid, password, age)) except Exception as e: mysql.rollback() logger.exception( "username:{},password:{},age:{} UPDATE filed".format( username, password, age)) return redirect(url_for('user')) except Exception as e: logger.exception("add user info error: {}".format(e)) return redirect(url_for('user'))
def editpassword(): """ 修改账号密码 :return: Userinfo.html """ userid = session['userid'] try: if request.method == 'POST': password1 = request.form['password1'] password2 = request.form['password2'] if password1 == password2: try: sql = "UPDATE User SET Location='{}' WHERE UserID='{}'".format( password1, userid) mysql.exe(sql) logger.info( "UPDATE password --> username:{},password:{} ".format( userid, password1)) except Exception as e: mysql.rollback() logger.exception( "username:{},password:{} UPDATE password filed".format( username, password1)) return redirect(url_for('user')) except Exception as e: logger.exception("add user info error: {}".format(e)) return redirect(url_for('user'))
def register(): """ 注册 :return: Register.html """ try: if request.method == 'POST': username = request.form['username'] password = request.form['password'] age = request.form['age'] try: sql = "insert into User (UserID,Location,Age) values ('{}','{}','{}')".format( username, password, age) mysql.exe(sql) logger.info( "username:{},password:{},age:{} register success".format( username, password, age)) except Exception as e: mysql.rollback() logger.exception( "username:{},password:{},age:{} register filed".format( username, password, age)) return render_template('Login.html') except Exception as e: logger.exception("register function error: {}".format(e)) return render_template('Register.html', error='注册出错')
def register(): """ 注册 :return: Register.html """ try: if request.method == 'POST': username = request.form['username'] try: #在此仅仅使用Userid,其他信息写死 sql = "insert into User (UserID,Location,Age) values ('{}','China','20')".format(username) mysql.exe(sql) except Exception as e: mysql.rollback() logger.exception("username:{} register filed".format(username)) return render_template('Login.html') except Exception as e: logger.exception("register function error: {}".format(e)) return render_template('Register.html', error='注册出错')