-- 作者:cxzhl
-- 发布时间:2020/9/7 23:38:00
-- 求网页用户注册时用户名不能重复的代码
Dim e As RequestEventArgs = args(0) \'注册第1页,注册 Dim wb As New weui Select Case e.Path Case "register.htm" If e.PostValues.Count = 0 Then wb.AddTopTips("","toptip1","") \'用于显示动态错误提示 wb.AddPageTitle("","pageheader","《众和出行》","比自驾更省钱的出行方式") wb.AddForm("","form1","register.htm").Attribute="" With wb.AddInputGroup("form1","ipg1","快速注册") With .AddInputCell("ic1") \'通过InputCell增加输入框(1表示突出显示,2表示红色警示图标) .AddLabel("手机号1","手机号",0) \'增加标签(0显示在左边) .AddInput("手机号","text",1).PlaceHolder= "请输入手机号" \'增加输入框(0靠左显示,1居中显示,2靠右显示) DataTables("用户").DataCols("手机号").Unique = False \'禁止手机号重复 End With .AddInput("openid","微信:","Text") With .AddInputCell("ic2") .AddLabel("lyz","验证",0) .AddInput("iyz","text",1).PlaceHolder= "请输入验证码" .AddVcodeButton("vyz","获取验证码",2) \'0靠左显示,1居中显示,2靠右显示 End With With .AddInputCell("ic3") .AddLabel("密码1","密码",0) .AddInput("密码","text",1).PlaceHolder= "请输入密码" End With .AddInput("上级推广码","上级推广码","Text").Placeholder = "为空表示由总平台推荐" .AddInput("注册日期","注册日期","date").Value = Date.Today() With .AddInput("推广码","我的推广码","text") .Value = Functions.Execute("tgmscID") \'利用自定义函数生成推广码. .Readonly = True End With \' .AddSelect("sxb","性别","|男|女") .AddSwitch("fuwuxieyi","同意协议") With wb.AddButtonGroup("form1","btg1",True) .Add("btn1", "注册", "submit") .Add("btn1", "查看服务协议", "","/zcxy.htm").Kind = 1 End With End With e.WriteString(wb.Build) Else Dim nms() As String = {"手机号","密码","注册日期","推广码"} \'不能为空的列名数组 For Each nm As String In nms If e.PostValues.ContainsKey(nm) = False Then \'生成错误提示页 With wb.AddMsgPage("","msgpage","增加失败", nm & "列不能为空!") .icon = "Warn" \'改变图标 .AddButton("btn1","返回").Attribute = "" End With e.WriteString(wb.Build) Return "" \'必须返回 End If Next nms = New String() {"手机号","openid","密码","上级推广码","注册日期","推广码"} \'重新定义了nms数组,增加了两列. Dim dr As DataRow = DataTables("用户").AddNew() For Each nm As String In nms If e.PostValues.ContainsKey(nm) Then dr(nm) = e.PostValues(nm) End If Next \'保存并生成增加成功提示页面 dr.save() With wb.AddMsgPage("","msgpage","注册成功","欢迎来到《众和出行》") \'生成成功提示页 .AddButton("btn1","登陆","logon.htm") End With e.WriteString(wb.Build) End If End Select
用了以上代码,但没解决问题 ,请老师指导哈!
|