def register(): # 从request.form中获取username、password、telephone信息 username = request.form.get('username', '') password = request.form.get('password', '') telephone = request.form.get('telephone', '') age = request.form.get('age', '') # 检查用户提交的数据 ok, result = models.validate_user_add(username, password, telephone, age) # 如果检查通过则添加到文件中 if ok: if models.add_user(username, password, telephone, age): ok = True result = '注册成功' else: ok = False result = '注册失败' return render_template('login.html', ok=ok, result=result, register_username=username, password=password, telephone=telephone, age=age)
def register(): username = request.form.get('username','') password = request.form.get('password','') age = request.form.get('age','') address = request.form.get('address','') ok,info = models.validate_user_add(username,password,age,address) if ok: models.add_user(username,password,age,address) info = '注册成功' return render_template('index.html',registerok=ok,registerinfo=info)
def register(): username = request.form.get('username','') password = request.form.get('password','') age = request.form.get('age','') address = request.form.get('address','') if models.query_user(username): return render_template('index.html', \ register_error='注册失败,用户名重复', \ username=username) elif isNone(password): return render_template('index.html', \ register_error='注册失败,密码为空', \ password=password) elif isNotNum(age): return render_template('index.html', \ register_error='注册失败,年龄必须为数字', \ username=username, \ password=password, \ age=age, \ address=address) else: models.validate_user_add(username,password,age,address) return '注册成功'
def register(): username = request.form.get('username', '') password = request.form.get('password', '') age = request.form.get('age', '') address = request.form.get('address', '') if models.query_user(username): return render_template('index.html', \ register_error='注册失败,用户名重复', \ username=username) elif isNone(password): return render_template('index.html', \ register_error='注册失败,密码为空', \ password=password) elif isNotNum(age): return render_template('index.html', \ register_error='注册失败,年龄必须为数字', \ username=username, \ password=password, \ age=age, \ address=address) else: models.validate_user_add(username, password, age, address) return '注册成功'
def register(): # 从request.form中获取username、password、telephone信息 username = request.form.get('username', '') password = request.form.get('password', '') telephone = request.form.get('telephone', '') # 对用户唯一性,手机号正确性检查 ok, result = models.validate_user_add(username, password, telephone) # 如果检查通过则添加到文件中 if ok: if models.add_user(username, password, telephone): ok = True result = '注册成功' else: ok = False result = '注册失败' return render_template('login.html', ok=ok, result=result, register_username=username, password=password, telephone=telephone)
def register(): username = request.form.get('username', '') password = request.form.get('password', '') age = request.form.get('age', '') address = request.form.get('address', '') ok, info = models.validate_user_add(username, password, age, address) if ok: models.add_user(username, password, age, address) info = '注册成功' return render_template('index.html', registerok=ok, registerinfo=info)
def addUser(): name = request.form.get('username', '') password = request.form.get('password', '') telephone = request.form.get('telephone', '') age = request.form.get('age', '') ok, result = models.validate_user_add(name, password, telephone, age) if ok: if models.add_user(name, password, telephone, age): ok = True result = u'注册成功' else: ok = False result = u'注册失败' if ok: return redirect(url_for('listUser')) else: return render_template('create.html', result=result, username=name, password=password, telephone=telephone, age=age)
def register(): name = request.form.get('username', '') password = request.form.get('password', '') telephone = request.form.get('telephone', '') age = request.form.get('age', '') # models.validate_user_add返回(True,'')或者('False',原因) ok, result = models.validate_user_add(name, password, telephone, age) if ok: # models.add_user的返回值会与0比较,返回True或者False if models.add_user(name, password, telephone, age): ok = True result = u'注册成功' else: ok = False result = u'注册失败' return render_template('login.html', ok=ok, result=result, username=name, password=password, telephone=telephone, age=age)
def register(): # 从request.form中获取username、password、telephone信息 username = request.form.get("username", "") password = request.form.get("password", "") telephone = request.form.get("telephone", "") age = request.form.get("age", "") # 检查用户提交的数据 ok, result = models.validate_user_add(username, password, telephone, age) # 如果检查通过则添加到文件中 if ok: if models.add_user(username, password, telephone, age): ok = True result = "注册成功" else: ok = False result = "注册失败" return render_template( "login.html", ok=ok, result=result, register_username=username, password=password, telephone=telephone, age=age )
def addUser(): # 从request.form中获取username、password、telephone信息 username = request.form.get('username', '') password = request.form.get('password', '') telephone = request.form.get('telephone', '') age = request.form.get('age', '') # 检查用户提交的数据 ok, result = models.validate_user_add(username, password, telephone, age) # 如果检查通过则添加到文件中 if ok: if models.add_user(username, password, telephone, age): ok = True result = '注册成功' else: ok = False result = '注册失败' if ok: return redirect('/users/') else: return render_template('create.html', result=result, register_username=username, password=password, telephone=telephone, age=age)
def addUser(): # 从request.form中获取username、password、telephone信息 username = request.form.get('username', '') password = request.form.get('password', '') telephone = request.form.get('telephone', '') age = request.form.get('age', '') # 检查用户提交的数据 ok, result = models.validate_user_add(username, password, telephone, age) # 如果检查通过则添加到文件中 if ok: if models.add_user(username, password, telephone, age): ok = True result = '注册成功' else: ok = False result = '注册失败' if ok: #return redirect('/users/') return json.dumps({'ok': True}) else: #return render_template('create.html', result=result, register_username=username, password=password, telephone=telephone, age=age) return json.dumps({'ok': False, 'result': result})