主页登陆注册系统主要代码
2005-08-05 16:43
369 查看
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data .OleDb ;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace todotnet_kinghome
{
/// <summary>
/// regest 的摘要说明。
/// </summary>
public class regest : System.Web.UI.Page
{
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator3;
protected System.Web.UI.WebControls.CompareValidator CompareValidator1;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator4;
protected System.Web.UI.WebControls.TextBox username;
protected System.Web.UI.WebControls.TextBox pasw;
protected System.Web.UI.WebControls.TextBox firpasw;
protected System.Web.UI.WebControls.TextBox sitedes;
protected System.Web.UI.WebControls.TextBox hobby;
protected System.Web.UI.WebControls.TextBox usermail;
protected System.Web.UI.WebControls.TextBox sitename;
protected System.Web.UI.WebControls.TextBox siteurl;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label wrong;
protected System.Web.UI.WebControls.TextBox oicq;
protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
private string check(string v)
{
v = v.Replace("'","");
v = Server.HtmlEncode(v);
return v;
}
public void Button1_click(object sender, System.EventArgs e)
{ string getusername=username.Text;
string getpasw=pasw.Text;
string getsitedes=sitedes.Text;
string gethobby=hobby.Text;
string getoicq=oicq.Text;
string getusermail=usermail.Text;
string getsitename=sitename.Text;
string getsiteurl=siteurl.Text;
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;";
string DataBase = Server.MapPath("db/hsjdata.mdb");
strConnection += "Data Source=" + DataBase;
string strSQL = "SELECT * FROM ps where username='" +getusername+ "'";
OleDbConnection objConnection = new OleDbConnection(strConnection);
OleDbCommand objCommand =new OleDbCommand(strSQL, objConnection);
OleDbDataReader objDataReader ;
objCommand.Connection.Open();
objDataReader = objCommand.ExecuteReader();
if (objDataReader.Read() == true)
{
wrong.Text = "对不起,该用户名已经被注册!";
return;}
objCommand.Connection.Close();
string sql = "insert into ps (pw,username,email,sitename,siteadr,sitedes,oicq,hobby) values ('" + check(pasw.Text) + "','"+ check(username.Text) + "','" + check(usermail.Text) + "','" +check(sitename.Text) + "','" + check(siteurl.Text) + "','" + check(sitedes.Text) + "','" + check(oicq.Text) + "','" + check(hobby.Text) + "')";
OleDbCommand addCommand =new OleDbCommand(sql, objConnection);
addCommand.Connection.Open();
addCommand.ExecuteNonQuery();
addCommand.Connection.Close();
Response.Write ("<script>alert(/"注册成功!点击确定按钮关闭窗口!/");window.close()</script>");
Response.End();
}
#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.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
##########################
<%@ Page language="c#" src="regest.aspx.cs" AutoEventWireup="false" Inherits="todotnet_kinghome.regest" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>用户注册</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<LINK href="note/common.css" type="text/css" rel="stylesheet">
<LINK href="note/pt.css" type="text/css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="note/9pt.css" type="text/css">
</HEAD>
<body bottomMargin="0" leftMargin="0" background="pic/gb1.jpg" topMargin="0" rightMargin="0" MS_POSITIONING="GridLayout">
<form id="regest" method="post" runat="server">
<p><FONT face="宋体"></FONT> </p>
<table borderColor="#aaaaff" cellSpacing="3" cellPadding="0" width="600" align="center" bgColor="#6699ff" border="1">
<tr>
<td bgColor="#330099">
<div align="center"><b class="common">请认真填写好以下栏目(带*号栏必填)</b></div>
</td>
</tr>
<tr bgColor="#3300cc">
<td bgColor="#330099">
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td class="pt" width="200">
<asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server" ForeColor="#D1D5FE" Font-Size="9pt" ErrorMessage="此处填写有错!" ControlToValidate="username"></asp:requiredfieldvalidator></td>
<td class="pt" width="80">*用户名:</td>
<td class="pt">
<asp:textbox id="username" runat="server" ForeColor="DeepSkyBlue" BackColor="#330099" Font-Size="9pt" MaxLength="20" Wrap="False"></asp:textbox> <span class="pt9">(20个字符以内)</span></td>
</tr>
</table>
</td>
</tr>
<tr bgColor="#3300cc">
<td bgColor="#330099">
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td class="pt" width="200">
<asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server" ForeColor="#D1D5FE" Font-Size="9pt" ErrorMessage="此处填写有错!" ControlToValidate="pasw"></asp:requiredfieldvalidator></td>
<td class="pt" width="80">*密码:</td>
<td class="pt">
<asp:textbox id="pasw" runat="server" ForeColor="DeepSkyBlue" BackColor="#330099" Font-Size="9pt" MaxLength="20" Wrap="False" TextMode="Password" Width="133px"></asp:textbox> <span class="pt9">(20个字符以内)</span></td>
</tr>
</table>
</td>
</tr>
<tr bgColor="#3300cc">
<td bgColor="#330099">
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td class="pt" width="200">
<asp:requiredfieldvalidator id="RequiredFieldValidator3" runat="server" ForeColor="#D1D5FE" Font-Size="9pt" ErrorMessage="此处填写有错!" ControlToValidate="firpasw"></asp:requiredfieldvalidator><asp:comparevalidator id="CompareValidator1" runat="server" ForeColor="#D1D5FE" Font-Size="9pt" ErrorMessage="此处填写有错!" ControlToValidate="firpasw" ControlToCompare="pasw"></asp:comparevalidator></td>
<td class="pt" width="80">*确认密码:</td>
<td class="pt">
<asp:textbox id="firpasw" runat="server" ForeColor="DeepSkyBlue" BackColor="#330099" Font-Size="9pt" MaxLength="20" Wrap="False" TextMode="Password" Width="134px"></asp:textbox> <span class="pt9">(核对密码)</span></td>
</tr>
</table>
</td>
</tr>
<tr bgColor="#3300cc">
<td bgColor="#330099"&
cfbe
gt;
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td class="pt" width="200">
<asp:requiredfieldvalidator id="RequiredFieldValidator4" runat="server" ForeColor="#D1D5FE" Font-Size="9pt" ErrorMessage="此处填写有错!" ControlToValidate="usermail"></asp:requiredfieldvalidator><asp:regularexpressionvalidator id="RegularExpressionValidator1" runat="server" ForeColor="#D1D5FE" Font-Size="9pt" ErrorMessage="此处填写有错!" ControlToValidate="usermail" ValidationExpression="/w+([-+.]/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*"></asp:regularexpressionvalidator></td>
<td class="pt" width="80">*E-Mail:</td>
<td class="pt9">
<asp:textbox id="usermail" runat="server" ForeColor="DeepSkyBlue" BackColor="#330099" Font-Size="9pt" MaxLength="50" Wrap="False"></asp:textbox> (用于找回密码)</td>
</tr>
</table>
</td>
</tr>
<tr bgColor="#3300cc">
<td bgColor="#330099">
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td class="pt" width="200"> </td>
<td class="pt" width="80">主页名称:</td>
<td class="pt9">
<asp:textbox id="sitename" runat="server" ForeColor="DeepSkyBlue" BackColor="#330099" Font-Size="9pt" MaxLength="20" Wrap="False"></asp:textbox> (20个字符以内)</td>
</tr>
</table>
</td>
</tr>
<tr bgColor="#3300cc">
<td bgColor="#330099">
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td class="pt" width="200"> </td>
<td class="pt" width="80">主页地址:</td>
<td class="pt9">
<asp:textbox id="siteurl" runat="server" ForeColor="DeepSkyBlue" BackColor="#330099" Font-Size="9pt" MaxLength="50" Wrap="False"></asp:textbox> (50个字符以内)</td>
</tr>
</table>
</td>
</tr>
<tr bgColor="#3300cc">
<td bgColor="#330099">
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td class="pt" width="200"> </td>
<td class="pt" width="80">主页介绍:</td>
<td class="pt9">
<asp:textbox id="sitedes" runat="server" ForeColor="DeepSkyBlue" BackColor="#330099" Font-Size="9pt" MaxLength="100" Rows="3"></asp:textbox> (100个字符以内)</td>
</tr>
</table>
</td>
</tr>
<tr bgColor="#3300cc">
<td bgColor="#330099">
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td class="pt" width="200"> </td>
<td class="pt" width="80">兴趣爱好:</td>
<td class="pt9">
<asp:textbox id="hobby" runat="server" ForeColor="DeepSkyBlue" BackColor="#330099" Font-Size="9pt" MaxLength="100" Rows="3"></asp:textbox> (100个字符以内)</td>
</tr>
</table>
</td>
</tr>
<tr bgColor="#3300cc">
<td bgColor="#330099">
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td width="200" class="pt"> </td>
<td width="80" class="pt">OICQ:</td>
<td class="pt9">
<asp:TextBox Font-Size="9pt" BackColor="#330099" ForeColor="DeepSkyBlue" id="oicq" runat="server" MaxLength="20" Wrap="False"></asp:TextBox> (5至10个数字)</td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#3300cc">
<td bgcolor="#330099" align="middle">
<asp:Button onmouseover="this.style.backgroundColor='#9900cc'" onmouseout="this.style.backgroundColor='#330099'" runat="server" onclick="Button1_click" Font-Size="9pt" BackColor="#330099" ForeColor="DeepSkyBlue" id="Button1" Text="注册"></asp:Button><FONT face="宋体">
<INPUT style=" FONT-SIZE: 9pt; COLOR: deepskyblue; BACKGROUND-COLOR: #330099" onmouseover="this.style.backgroundColor='#9900cc'" onmouseout="this.style.backgroundColor='#330099'" type="reset" value="重写"></FONT>
</td>
</tr>
<tr bgcolor="#3300cc">
<td bgcolor="#330099" align="middle">
<asp:Label Font-Size="9pt" BackColor="#330099" ForeColor="#C0C0FF" id="wrong" runat="server"></asp:Label>
</td>
</tr>
<tr bgcolor="#3300cc">
<td bgcolor="#330099" class="pt"> <font color="#66ffff">
<font color="#d1d5fe">注意:当你填写的资料长度大于要求的长度时,系统会自动把多余的资料删去!另,当你填写主页地址时请务必保持HTTP://的存在,否则链接将会出错!非必填项系统将不作检测,你完全可以选择不填!</font></font></td>
</tr>
</table>
<p>
</p>
</form>
</body>
</HTML>
################################################
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.Xml ;
namespace todotnet_kinghome
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
public string countvisit;
protected System.Web.UI.WebControls.TextBox username;
protected System.Web.UI.WebControls.TextBox pasw;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label wel;
protected System.Web.UI.WebControls.Calendar Calendar1;
protected System.Web.UI.WebControls.RadioButton vbnet;
protected System.Web.UI.WebControls.RadioButton csharp;
protected System.Web.UI.WebControls.RadioButton asp;
protected System.Web.UI.WebControls.RadioButton php;
protected System.Web.UI.WebControls.Button vote;
protected System.Web.UI.WebControls.DataGrid mysoft;
protected System.Web.UI.WebControls.DataGrid websoft;
public string countreg;
private void Page_Load(object sender, System.EventArgs e)
{
Session.Timeout =20;
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;";
string DataBase = Server.MapPath("db/hsjdata.mdb");
strConnection += "Data Source=" + DataBase;
string strSQL = "SELECT * FROM ps where username='all'";
OleDbConnection objConnection = new OleDbConnection(strConnection);
OleDbCommand objCommand =new OleDbCommand(strSQL, objConnection);
if (Session["guestin"]!="hasin")
{Application.Lock() ;
Session["guestin"]="hasin";
string upsql = "UPDATE ps SET visitime=visitime+1 where username='all'";
OleDbCommand upcommand =new OleDbCommand(upsql, objConnection);
upcommand.Connection.Open();
upcommand.ExecuteNonQuery();
upcommand.Connection.Close();
Application.UnLock() ;}
OleDbDataReader objDataReader ;
objCommand.Connection.Open();
objDataReader = objCommand.ExecuteReader();
if (objDataReader.Read() == true)
{countvisit=objDataReader.GetValue(3).ToString();}
objCommand.Connection.Close();
strSQL = "select * from ps order by id desc";
objCommand.Connection.Open();
objDataReader = objCommand.ExecuteReader();
if (objDataReader.Read() == true)
countreg = objDataReader.GetValue(1).ToString();
objCommand.Connection.Close();
}
public void Button1_click(object sender, System.EventArgs e)
{
Session["username"]=username.Text ;
string getpasw=pasw.Text ;
if (Session["username"]=="" || getpasw=="")
{
wel.Text="请输入完整资料!";
return;}
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;";
string DataBase = Server.MapPath("db/hsjdata.mdb");
strConnection += "Data Source=" + DataBase;
string strSQL = "SELECT * FROM ps where username='" + Session["username"]+ "'";
OleDbConnection objConnection = new OleDbConnection(strConnection);
OleDbCommand objCommand =new OleDbCommand(strSQL, objConnection);
OleDbDataReader objDataReader ;
objCommand.Connection.Open();
objDataReader = objCommand.ExecuteReader();
if (objDataReader.Read() == false)
{
wel.Text = "该用户名还未注册!";
return;}
else if(objDataReader.GetString(2)!=getpasw)
{
wel.Text="密码错误!";
return;}
else
{ string times= objDataReader.GetValue(3).ToString() ;
if (Session["username.text"] == "hasin" )
{wel.Text = "欢迎" + Session["username"] + "重新登陆本站!";
return;}
else
wel.Text = "欢迎" + Session["username"] + "第" + times + "次登陆本站!";
string upsql = "UPDATE ps SET visitime=visitime+1 where username='" + Session["username"] + "'";
OleDbCommand upcommand = new OleDbCommand(upsql, objConnection);
objCommand.Connection.Close();
upcommand.Connection.Open();
upcommand.ExecuteNonQuery();
upcommand.Connection.Close();
Session["username.text"]= "hasin";
}
}
#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.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data .OleDb ;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace todotnet_kinghome
{
/// <summary>
/// regest 的摘要说明。
/// </summary>
public class regest : System.Web.UI.Page
{
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator3;
protected System.Web.UI.WebControls.CompareValidator CompareValidator1;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator4;
protected System.Web.UI.WebControls.TextBox username;
protected System.Web.UI.WebControls.TextBox pasw;
protected System.Web.UI.WebControls.TextBox firpasw;
protected System.Web.UI.WebControls.TextBox sitedes;
protected System.Web.UI.WebControls.TextBox hobby;
protected System.Web.UI.WebControls.TextBox usermail;
protected System.Web.UI.WebControls.TextBox sitename;
protected System.Web.UI.WebControls.TextBox siteurl;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label wrong;
protected System.Web.UI.WebControls.TextBox oicq;
protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
private string check(string v)
{
v = v.Replace("'","");
v = Server.HtmlEncode(v);
return v;
}
public void Button1_click(object sender, System.EventArgs e)
{ string getusername=username.Text;
string getpasw=pasw.Text;
string getsitedes=sitedes.Text;
string gethobby=hobby.Text;
string getoicq=oicq.Text;
string getusermail=usermail.Text;
string getsitename=sitename.Text;
string getsiteurl=siteurl.Text;
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;";
string DataBase = Server.MapPath("db/hsjdata.mdb");
strConnection += "Data Source=" + DataBase;
string strSQL = "SELECT * FROM ps where username='" +getusername+ "'";
OleDbConnection objConnection = new OleDbConnection(strConnection);
OleDbCommand objCommand =new OleDbCommand(strSQL, objConnection);
OleDbDataReader objDataReader ;
objCommand.Connection.Open();
objDataReader = objCommand.ExecuteReader();
if (objDataReader.Read() == true)
{
wrong.Text = "对不起,该用户名已经被注册!";
return;}
objCommand.Connection.Close();
string sql = "insert into ps (pw,username,email,sitename,siteadr,sitedes,oicq,hobby) values ('" + check(pasw.Text) + "','"+ check(username.Text) + "','" + check(usermail.Text) + "','" +check(sitename.Text) + "','" + check(siteurl.Text) + "','" + check(sitedes.Text) + "','" + check(oicq.Text) + "','" + check(hobby.Text) + "')";
OleDbCommand addCommand =new OleDbCommand(sql, objConnection);
addCommand.Connection.Open();
addCommand.ExecuteNonQuery();
addCommand.Connection.Close();
Response.Write ("<script>alert(/"注册成功!点击确定按钮关闭窗口!/");window.close()</script>");
Response.End();
}
#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.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
##########################
<%@ Page language="c#" src="regest.aspx.cs" AutoEventWireup="false" Inherits="todotnet_kinghome.regest" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>用户注册</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<LINK href="note/common.css" type="text/css" rel="stylesheet">
<LINK href="note/pt.css" type="text/css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="note/9pt.css" type="text/css">
</HEAD>
<body bottomMargin="0" leftMargin="0" background="pic/gb1.jpg" topMargin="0" rightMargin="0" MS_POSITIONING="GridLayout">
<form id="regest" method="post" runat="server">
<p><FONT face="宋体"></FONT> </p>
<table borderColor="#aaaaff" cellSpacing="3" cellPadding="0" width="600" align="center" bgColor="#6699ff" border="1">
<tr>
<td bgColor="#330099">
<div align="center"><b class="common">请认真填写好以下栏目(带*号栏必填)</b></div>
</td>
</tr>
<tr bgColor="#3300cc">
<td bgColor="#330099">
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td class="pt" width="200">
<asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server" ForeColor="#D1D5FE" Font-Size="9pt" ErrorMessage="此处填写有错!" ControlToValidate="username"></asp:requiredfieldvalidator></td>
<td class="pt" width="80">*用户名:</td>
<td class="pt">
<asp:textbox id="username" runat="server" ForeColor="DeepSkyBlue" BackColor="#330099" Font-Size="9pt" MaxLength="20" Wrap="False"></asp:textbox> <span class="pt9">(20个字符以内)</span></td>
</tr>
</table>
</td>
</tr>
<tr bgColor="#3300cc">
<td bgColor="#330099">
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td class="pt" width="200">
<asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server" ForeColor="#D1D5FE" Font-Size="9pt" ErrorMessage="此处填写有错!" ControlToValidate="pasw"></asp:requiredfieldvalidator></td>
<td class="pt" width="80">*密码:</td>
<td class="pt">
<asp:textbox id="pasw" runat="server" ForeColor="DeepSkyBlue" BackColor="#330099" Font-Size="9pt" MaxLength="20" Wrap="False" TextMode="Password" Width="133px"></asp:textbox> <span class="pt9">(20个字符以内)</span></td>
</tr>
</table>
</td>
</tr>
<tr bgColor="#3300cc">
<td bgColor="#330099">
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td class="pt" width="200">
<asp:requiredfieldvalidator id="RequiredFieldValidator3" runat="server" ForeColor="#D1D5FE" Font-Size="9pt" ErrorMessage="此处填写有错!" ControlToValidate="firpasw"></asp:requiredfieldvalidator><asp:comparevalidator id="CompareValidator1" runat="server" ForeColor="#D1D5FE" Font-Size="9pt" ErrorMessage="此处填写有错!" ControlToValidate="firpasw" ControlToCompare="pasw"></asp:comparevalidator></td>
<td class="pt" width="80">*确认密码:</td>
<td class="pt">
<asp:textbox id="firpasw" runat="server" ForeColor="DeepSkyBlue" BackColor="#330099" Font-Size="9pt" MaxLength="20" Wrap="False" TextMode="Password" Width="134px"></asp:textbox> <span class="pt9">(核对密码)</span></td>
</tr>
</table>
</td>
</tr>
<tr bgColor="#3300cc">
<td bgColor="#330099"&
cfbe
gt;
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td class="pt" width="200">
<asp:requiredfieldvalidator id="RequiredFieldValidator4" runat="server" ForeColor="#D1D5FE" Font-Size="9pt" ErrorMessage="此处填写有错!" ControlToValidate="usermail"></asp:requiredfieldvalidator><asp:regularexpressionvalidator id="RegularExpressionValidator1" runat="server" ForeColor="#D1D5FE" Font-Size="9pt" ErrorMessage="此处填写有错!" ControlToValidate="usermail" ValidationExpression="/w+([-+.]/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*"></asp:regularexpressionvalidator></td>
<td class="pt" width="80">*E-Mail:</td>
<td class="pt9">
<asp:textbox id="usermail" runat="server" ForeColor="DeepSkyBlue" BackColor="#330099" Font-Size="9pt" MaxLength="50" Wrap="False"></asp:textbox> (用于找回密码)</td>
</tr>
</table>
</td>
</tr>
<tr bgColor="#3300cc">
<td bgColor="#330099">
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td class="pt" width="200"> </td>
<td class="pt" width="80">主页名称:</td>
<td class="pt9">
<asp:textbox id="sitename" runat="server" ForeColor="DeepSkyBlue" BackColor="#330099" Font-Size="9pt" MaxLength="20" Wrap="False"></asp:textbox> (20个字符以内)</td>
</tr>
</table>
</td>
</tr>
<tr bgColor="#3300cc">
<td bgColor="#330099">
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td class="pt" width="200"> </td>
<td class="pt" width="80">主页地址:</td>
<td class="pt9">
<asp:textbox id="siteurl" runat="server" ForeColor="DeepSkyBlue" BackColor="#330099" Font-Size="9pt" MaxLength="50" Wrap="False"></asp:textbox> (50个字符以内)</td>
</tr>
</table>
</td>
</tr>
<tr bgColor="#3300cc">
<td bgColor="#330099">
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td class="pt" width="200"> </td>
<td class="pt" width="80">主页介绍:</td>
<td class="pt9">
<asp:textbox id="sitedes" runat="server" ForeColor="DeepSkyBlue" BackColor="#330099" Font-Size="9pt" MaxLength="100" Rows="3"></asp:textbox> (100个字符以内)</td>
</tr>
</table>
</td>
</tr>
<tr bgColor="#3300cc">
<td bgColor="#330099">
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td class="pt" width="200"> </td>
<td class="pt" width="80">兴趣爱好:</td>
<td class="pt9">
<asp:textbox id="hobby" runat="server" ForeColor="DeepSkyBlue" BackColor="#330099" Font-Size="9pt" MaxLength="100" Rows="3"></asp:textbox> (100个字符以内)</td>
</tr>
</table>
</td>
</tr>
<tr bgColor="#3300cc">
<td bgColor="#330099">
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td width="200" class="pt"> </td>
<td width="80" class="pt">OICQ:</td>
<td class="pt9">
<asp:TextBox Font-Size="9pt" BackColor="#330099" ForeColor="DeepSkyBlue" id="oicq" runat="server" MaxLength="20" Wrap="False"></asp:TextBox> (5至10个数字)</td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#3300cc">
<td bgcolor="#330099" align="middle">
<asp:Button onmouseover="this.style.backgroundColor='#9900cc'" onmouseout="this.style.backgroundColor='#330099'" runat="server" onclick="Button1_click" Font-Size="9pt" BackColor="#330099" ForeColor="DeepSkyBlue" id="Button1" Text="注册"></asp:Button><FONT face="宋体">
<INPUT style=" FONT-SIZE: 9pt; COLOR: deepskyblue; BACKGROUND-COLOR: #330099" onmouseover="this.style.backgroundColor='#9900cc'" onmouseout="this.style.backgroundColor='#330099'" type="reset" value="重写"></FONT>
</td>
</tr>
<tr bgcolor="#3300cc">
<td bgcolor="#330099" align="middle">
<asp:Label Font-Size="9pt" BackColor="#330099" ForeColor="#C0C0FF" id="wrong" runat="server"></asp:Label>
</td>
</tr>
<tr bgcolor="#3300cc">
<td bgcolor="#330099" class="pt"> <font color="#66ffff">
<font color="#d1d5fe">注意:当你填写的资料长度大于要求的长度时,系统会自动把多余的资料删去!另,当你填写主页地址时请务必保持HTTP://的存在,否则链接将会出错!非必填项系统将不作检测,你完全可以选择不填!</font></font></td>
</tr>
</table>
<p>
</p>
</form>
</body>
</HTML>
################################################
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.Xml ;
namespace todotnet_kinghome
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
public string countvisit;
protected System.Web.UI.WebControls.TextBox username;
protected System.Web.UI.WebControls.TextBox pasw;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label wel;
protected System.Web.UI.WebControls.Calendar Calendar1;
protected System.Web.UI.WebControls.RadioButton vbnet;
protected System.Web.UI.WebControls.RadioButton csharp;
protected System.Web.UI.WebControls.RadioButton asp;
protected System.Web.UI.WebControls.RadioButton php;
protected System.Web.UI.WebControls.Button vote;
protected System.Web.UI.WebControls.DataGrid mysoft;
protected System.Web.UI.WebControls.DataGrid websoft;
public string countreg;
private void Page_Load(object sender, System.EventArgs e)
{
Session.Timeout =20;
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;";
string DataBase = Server.MapPath("db/hsjdata.mdb");
strConnection += "Data Source=" + DataBase;
string strSQL = "SELECT * FROM ps where username='all'";
OleDbConnection objConnection = new OleDbConnection(strConnection);
OleDbCommand objCommand =new OleDbCommand(strSQL, objConnection);
if (Session["guestin"]!="hasin")
{Application.Lock() ;
Session["guestin"]="hasin";
string upsql = "UPDATE ps SET visitime=visitime+1 where username='all'";
OleDbCommand upcommand =new OleDbCommand(upsql, objConnection);
upcommand.Connection.Open();
upcommand.ExecuteNonQuery();
upcommand.Connection.Close();
Application.UnLock() ;}
OleDbDataReader objDataReader ;
objCommand.Connection.Open();
objDataReader = objCommand.ExecuteReader();
if (objDataReader.Read() == true)
{countvisit=objDataReader.GetValue(3).ToString();}
objCommand.Connection.Close();
strSQL = "select * from ps order by id desc";
objCommand.Connection.Open();
objDataReader = objCommand.ExecuteReader();
if (objDataReader.Read() == true)
countreg = objDataReader.GetValue(1).ToString();
objCommand.Connection.Close();
}
public void Button1_click(object sender, System.EventArgs e)
{
Session["username"]=username.Text ;
string getpasw=pasw.Text ;
if (Session["username"]=="" || getpasw=="")
{
wel.Text="请输入完整资料!";
return;}
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;";
string DataBase = Server.MapPath("db/hsjdata.mdb");
strConnection += "Data Source=" + DataBase;
string strSQL = "SELECT * FROM ps where username='" + Session["username"]+ "'";
OleDbConnection objConnection = new OleDbConnection(strConnection);
OleDbCommand objCommand =new OleDbCommand(strSQL, objConnection);
OleDbDataReader objDataReader ;
objCommand.Connection.Open();
objDataReader = objCommand.ExecuteReader();
if (objDataReader.Read() == false)
{
wel.Text = "该用户名还未注册!";
return;}
else if(objDataReader.GetString(2)!=getpasw)
{
wel.Text="密码错误!";
return;}
else
{ string times= objDataReader.GetValue(3).ToString() ;
if (Session["username.text"] == "hasin" )
{wel.Text = "欢迎" + Session["username"] + "重新登陆本站!";
return;}
else
wel.Text = "欢迎" + Session["username"] + "第" + times + "次登陆本站!";
string upsql = "UPDATE ps SET visitime=visitime+1 where username='" + Session["username"] + "'";
OleDbCommand upcommand = new OleDbCommand(upsql, objConnection);
objCommand.Connection.Close();
upcommand.Connection.Open();
upcommand.ExecuteNonQuery();
upcommand.Connection.Close();
Session["username.text"]= "hasin";
}
}
#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.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
相关文章推荐
- JAVA实现简单系统登陆注册模块的设计(附详细代码分析)
- .net 批处理注册系统服务 cmd com 代码 最简单的注册服务方式
- java登陆注册界面参考的资料和代码
- [置顶] 针对 android端模拟教务系统登陆,主要针对抓包过程,post,get请求,和解析网页和cookie(二)
- Nodejs使用coffeescript编写的用户注册/登陆代码(MySQL)
- 简单的asp.net模拟邮箱系统基础实现(二 (1)具体版块功能的实现及关键代码之注册页面)
- Android第一行代码阅读笔记001 主要文件夹介绍、activity的注册、资源引用的方法、Log日志打印的使用
- Node.js Express连接mysql完整的登陆注册系统(windows)
- 分享实现类似QQ的自动登陆的方法,代码比较简单,主要是给大家提供一个实现逻辑,具体的要结合自身的app来做
- 【求助,已经解决】未能注册sharepoint服务。已引发类型为SYSTEM.ARGUMENTEXCEPTION异常,其他异常信息,加密和解密过程中出错,系统错误代码为997
- php mysql用户注册登陆代码
- JAVA简单链接Oracle数据库 注册和登陆功能的实现代码
- Servlet登陆注册管理系统2.0
- 一个注册、登陆系统的实现
- 4000 Node.js Express连接mysql完整的登陆注册系统(windows)
- 一个简单的登陆注册系统
- 利用python实现简单登陆注册系统
- ASP.NET 登陆与注册代码
- [置顶] 针对 android端模拟教务系统登陆,主要针对抓包过程,post,get请求,和解析网页和cookie(一)