</tr>
<tr><td><label for="password2">再次输入密码:</label></td><td><input type="password" /><label></label></td></tr>
<tr><td><label>邮箱:</label></td><td><input type="text" /><span></span></td></tr>
<tr><td><label>手机号:</label></td><td><input type="text" /><span></span></td></tr>
<tr><td><label>QQ:</label></td><td><input type="text" /><span></span></td></tr>
<tr><td><label>学校:</label></td><td><input type="text"/><span></span></td></tr>
<tr><td><label>验证码:</label></td><td><input type="text" /><img src="https://www.linuxidc.com/UserController.ashx?action=createValideCode" /><span></span></td></tr>
<tr><td><input type="button" value="注册" /></td><td></td></tr>
</table>
</main>
<!--#include file="/html/foot.html"-->
一般处理程序:
/// <summary>
/// 用户注册
/// </summary>
/// <param></param>
public void registerSubmit(HttpContext context)
{
//获取请求报文中从浏览器传过来的数据
string username = context.Request["username"];
string password = context.Request["password"];
string email = context.Request["email"];
string phone = context.Request["phone"];
string qq = context.Request["qq"];
string school = context.Request["school"];
string validCode = context.Request["validCode"];
//注意:通过js进行数据合法性校验,只是为了用户用起来方便而已,在服务器中校验才能保证数据的安全。
if (string.IsNullOrWhiteSpace(phone))
{
AjaxHelper.WriteJson(context.Response, "error", "手机号不能为空!");
return;
}
if (string.IsNullOrWhiteSpace(qq))
{
AjaxHelper.WriteJson(context.Response,"error","QQ号不能为空!");
return;
}
if (string.IsNullOrWhiteSpace(school))
{
AjaxHelper.WriteJson(context.Response,"error","学校不能为空!");
return;
}
if (string.IsNullOrWhiteSpace(username))
{
AjaxHelper.WriteJson(context.Response,"error","用户名不能为空!");
return;
}
if (string.IsNullOrWhiteSpace(password))
{
AjaxHelper.WriteJson(context.Response,"error","密码不能为空!");
return;
}
if (string.IsNullOrWhiteSpace(email))
{
AjaxHelper.WriteJson(context.Response,"error","邮箱不能为空!");
return;
}
if (string.IsNullOrWhiteSpace(validCode))
{
AjaxHelper.WriteJson(context.Response,"error","验证码不能为空!");
return;
}
if (validCode!=CommonHelper.GetValidCode(context))
{
AjaxHelper.WriteJson(context.Response,"error","验证码错误");
CommonHelper.ResetValidCode(context);
return;
}
T_UsersBLL userBll = new T_UsersBLL();
if (!userBll.CheckUserNameOnReg(username))
{
AjaxHelper.WriteJson(context.Response,"error","当前用户不可用");
return;
}
if (!userBll.CheckEmailOnReg(email))
{
AjaxHelper.WriteJson(context.Response,"error","该邮箱已被注册!");
return;
}
//插入数据库(T_Users)
long userId = userBll.AddNewUser(username, password, email,phone,qq,school);
//激活码
Random rand = new Random();
string activeCode = rand.Next(10000,99999).ToString();