示例#1
0
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)
示例#2
0
文件: views.py 项目: zhangbei4536/hw-
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.addtime = time.time()
                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)
示例#3
0
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)
示例#4
0
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)
示例#5
0
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)
示例#6
0
文件: views.py 项目: LinQiH/PyWeb
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)
示例#7
0
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)
示例#8
0
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")
示例#9
0
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)