📄 reg.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Security;
using System.Text.RegularExpressions;
namespace xajh
{
/// <summary>
/// reg 的摘要说明。
/// </summary>
public class reg : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox byts_username;
protected System.Web.UI.WebControls.TextBox byts_password;
protected System.Web.UI.WebControls.Button byts_submit;
protected System.Web.UI.WebControls.TextBox byts_email;
protected System.Web.UI.WebControls.TextBox byts_oicq;
protected System.Web.UI.WebControls.DropDownList byts_sex;
protected System.Web.UI.HtmlControls.HtmlInputHidden byts_ico;
protected System.Web.UI.WebControls.Label byts_copyright;
protected System.Web.UI.WebControls.Literal byts_errormsg;
private void Page_Load(object sender, System.EventArgs e)
{
if (!this.Page.IsPostBack)
{
this.byts_username.Text = this.Request.QueryString["v"];
this.byts_copyright.Text = "授权给:<font class=\"byts\">" + var.public_user + "</font><br />序列号:<font class=\"byts\">" + var.public_sn + "</font><br />作者<font class=\"byts\"><a target=_blank href=http://9diy.net/go.aspx?type=aboutme>变异天使</a></font>保留所有权利";
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.byts_submit.Click += new System.EventHandler(this.byts_submit_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void byts_submit_Click(object sender, System.EventArgs e)
{
string username = this.byts_username.Text.Trim();
string password = this.byts_password.Text.Trim();
string sex = this.byts_sex.SelectedItem.Value.Trim();
string email = this.byts_email.Text.Trim();
string oicq = this.byts_oicq.Text.Trim();
int ico = int.Parse(this.byts_ico.Value);
if (username == "")
{
this.byts_errormsg.Text = "用户名不能为空!";
return;
}
if (password == "")
{
this.byts_errormsg.Text = "密码不能为空!";
return;
}
for (int i = 0; i < username.Length; i ++)
{
if ((int) username[i] < 19968 || (int) username[i] > 40870)
{
this.byts_errormsg.Text = "用户名非法!用户名只能使用中文!";
return;
}
}
if (username.Length > 5)
{
this.byts_errormsg.Text = "用户名长度不能超过5字符!";
return;
}
if (username == "大家")
{
this.byts_errormsg.Text = "用户名不能使用 大家!";
return;
}
if (password.Length < 4)
{
this.byts_errormsg.Text = "密码至少需要4位!";
return;
}
if (password == "1111" || password == "0000" || password == "8888" || password == "aaaa" || password == "abcd")
{
this.byts_errormsg.Text = "密码太过于简单,容易被他人猜到!";
return;
}
if (ico > 84 || ico < 0)
{
this.byts_errormsg.Text = "请选择正确的头像!";
return;
}
if (sex != "boy" && sex != "girl")
{
this.byts_errormsg.Text = "请选择正确的性别!";
return;
}
if (oicq.Length < 5 || oicq.Length > 9)
{
this.byts_errormsg.Text = "QQ号码长度有错误!";
return;
}
for (int i = 0; i < oicq.Length; i ++)
{
if (char.IsNumber(oicq,i) != true)
{
this.byts_errormsg.Text = "QQ号码必须为数字!";
return;
}
}
Regex emailregex = new Regex(@"[\w-]+@([\w-]+\.)+[\w-]+");
if (!emailregex.IsMatch(email))
{
this.byts_errormsg.Text = "电子邮件格式错误!";
return;
}
OleDbConnection MyConn = new OleDbConnection(var.public_conn);
MyConn.Open();
OleDbCommand MyComm = new OleDbCommand(@"select null from [注册用户] where [用户名]='" + username + "'",MyConn);
OleDbDataReader dr = MyComm.ExecuteReader();
if (dr.Read())
{
dr.Close();
MyConn.Close();
MyConn.Dispose();
this.byts_errormsg.Text = "该帐号已经存在,不能重复注册!";
}
else
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -