def doregister(request): try: user = Users.objects.all() if user.filter(username=request.POST['username']): context = {'info':'此用户名已经注册!'} else: ob = Users() ob.username = request.POST['username'] ob.name = request.POST['name'] import hashlib m = hashlib.md5() m.update(bytes(request.POST['password'],encoding="utf8")) ob.password = m.hexdigest() if request.POST['password'] == request.POST['repassword']: ob.address = request.POST['address'] ob.email = request.POST['email'] ob.phone = request.POST['phone'] ob.code = request.POST['code'] ob.save() return render(request,"myweb/login.html") else: context = {'info':'请重新确认密码!'} return render(request,"myweb/register.html",context) except: context = {'info':'注册失败啦!'} return render(request,"myweb/info.html",context)
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 userinsert(request): try: ob = Users() ob.username = request.POST['username'] ob.password = request.POST['password'] ob.name = request.POST['name'] ob.email = request.POST['email'] ob.save() context = {'info':'注册成功!'} except: context = {'info':'注册失败!'} return render(request,'myweb/meizu/register.html',context)
def doregister(request): import hashlib m = hashlib.md5() m.update(bytes(request.POST['password'], encoding="utf8")) n = hashlib.md5() n.update(bytes(request.POST['cpassword'], encoding="utf8")) try: import re name = request.POST['name'] username = request.POST['username'] password = request.POST['password'] cpassword = request.POST['cpassword'] phone = request.POST['phone'] email = request.POST['email'] if re.match(r'\w{2,6}', name): if re.match(r'^[a-zA-Z0-9_-]{4,16}$', username): if re.match(r'\w{6,15}', password): if m.hexdigest() == n.hexdigest(): if re.match( r'^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\d{8}$', phone): if re.match( r'^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$', email): context = {'info': '恭喜您注册成功,可以登录!'} ob = Users() ob.name = name ob.username = username ob.password = m.hexdigest() # ob.cpassword = cpassword ob.phone = phone ob.email = email ob.save() return render(request, 'myweb/register.html', context) else: context = {'info': '邮箱不合法!'} else: context = {'info': '手机号不合法!'} else: context = {'info': '两次密码不同,请确认'} else: context = {'info': '密码不合法!'} else: context = {'info': '账号不合法!'} else: context = {'info': '姓名不合法!'} return render(request, 'myweb/register.html', context) except: context = {'info': '用户名已存在!'} return render(request, 'myweb/register.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 doregister(request): user = Users.objects.filter(username=request.POST['username']) if user.exists(): info = "用户已存在" else: user = Users() user.username = request.POST['username'] m = hashlib.md5() m.update(bytes(request.POST['passwd'], encoding="utf8")) user.passwd = m.hexdigest() user.email = request.POST['email'] user.addtime = time.strftime('%Y%m%d%H%M', time.localtime()) try: user.save() info = "注册成功" content = {'info': info} return render(request, 'myweb/info.html', content) except: info = "注册失败" content = {'info': info} return render(request, 'myweb/register.html', content)
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 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)