def doregister(request): # try: users = Users.objects.all() if users.filter(phone=request.POST['phone']): context = {'info': '该手机号已注册!'} else: ob = Users() ob.username = request.POST['username'] ob.name = request.POST['name'] if request.POST['password'] == request.POST['repassword']: # 获取密码并md5 import hashlib m = hashlib.md5() m.update(bytes(request.POST['password'], encoding="utf8")) ob.password = m.hexdigest() ob.phone = request.POST['phone'] ob.email = request.POST['email'] ob.state = 1 ob.addtime = time.time() ob.save() return redirect(reverse('myweb_login')) else: context = {'info': '重复密码错误!'} # except: # context = {'info': '添加失败!'} return render(request, "myweb/register.html", context)
def usersinsert(request): ob = Users() ob.username = request.POST['uname'] ob.password = request.POST['password'] #获取密码并md5 import hashlib m = hashlib.md5() m.update(bytes(request.POST['password'], encoding="utf8")) ob.password = m.hexdigest() ob.username = request.POST['uname'] ob.state = 1 ob.addtime = time.time() ob.save() context = {'info': '注册成功!'} return render(request, "myweb/users/login.html", context)
def doregister(request): try: ob = Users() ob.phone = request.POST['phone'] ob.username = request.POST['username'] # 获取密码并md5 import hashlib m = hashlib.md5() m.update(bytes(request.POST['password'], encoding="utf8")) ob.psssword = m.hexdigest() ob.state = 1 ob.addtime = time.time() ob.save() context = {'info': '注册成功,请登录!'} return render(request, "myweb/info.html", context) except: context = {'info': '注册失败!'} return render(request, "myweb/info.html", context)
def zhuce1(request): try: ob = Users() ob.username = request.POST['username'] #获取密码并md5 import hashlib m = hashlib.md5() m.update(bytes(request.POST['password'], encoding="utf8")) ob.password = m.hexdigest() ob.phone = request.POST['phone'] ob.state = 1 ob.email = request.POST['email'] ob.addtime = time.time() ob.save() context = {'info': '注册成功!'} except: context = {'info': '注册失败!'} return render(request, "myweb/member/register.html", context)
def shopinsert(request): try: ob = Users() ob.username = request.POST['username'] ob.name = '请输入用户名' #获取密码并md5 import hashlib m = hashlib.md5() m.update(bytes(request.POST['password'], encoding="utf8")) ob.password = m.hexdigest() ob.sex = 1 ob.address = '北京' ob.code = 0 ob.phone = 0 ob.email = '100000' ob.state = 1 ob.addtime = time.time() ob.save() context = {'info': '添加成功!'} except: context = {'info': '添加失败!'} return render(request, "myweb/shoplogin.html", context)
def doregister(request): try: ob = Users() ob.username = request.POST['username'] ob.name = request.POST['name'] a = len(ob.username) if a == 11 and request.POST['password'] != '': # 获取密码并md5 import hashlib m = hashlib.md5() m.update(bytes(request.POST['password'], encoding="utf8")) ob.password = m.hexdigest() ob.state = 1 ob.save() context = {'info': '注册成功!'} print(context) else: return render(request,'myweb/register.html',context) except: context = {'info': '注册失败!'} return render(request, "myweb/info.html", context)
def registerzc(request): try: users = Users.objects.all() if users.filter(phone=request.POST['phone']): context = {'info': '手机号已存在!'} else: ob = Users() ob.username = request.POST['username'] ob.name = request.POST['name'] # 获取密码并md5 import hashlib m = hashlib.md5() m.update(bytes(request.POST['password'])) ob.password = m.hexdigest() ob.phone = request.POST['phone'] ob.email = request.POST['email'] ob.state = 1 ob.addtime = time.time() ob.save() context = {'info': '添加成功!'} except: context = {'info': '添加失败!'} # return render(request, "myweb/info.html", context) return render(request, "myweb/login.html")
def userinsert(request): try: a=Users() a.username=request.POST["username"] a.name=request.POST['name'] import hashlib m=hashlib.md5() m.update(bytes(request.POST['password'],encoding='utf8')) a.password=m.hexdigest() a.sex=request.POST['sex'] a.address=request.POST['address'] a.code=request.POST['code'] a.phone=request.POST['phone'] a.email=request.POST['email'] a.state=1 a.addtime=time.time() a.save() context = {'info':'添加成功请登录'} return render(request,'myweb/login.html',context) except: context={'info':'添加失败'} return render(request,'myweb/add.html',context)