小弟刚开始学.net,请大家给一些登陆,注册方面的一些思路啊,能提供一些小的代码或程序最好,先谢谢了!
解决方案 »
- 手机验证
- asp.net 向数据库写入html脚本出错怎么解决啊
- 页面回发后样式表不管用
- 水晶报表执行交叉表的时候,出现乱码问题,sql数据库的中文数据都乱码,怎么解决,请指教
- 无法表述或者形容的问题(暂且称为字母输入识别排序吧)
- asp.net 高手进来看看这个古怪的问题
- datagrid就地编辑的问题!
- 二次开发时遇到的问题!(Windows应用程序下的代码转到ASP下就不行了)
- 如何在状态栏上显示一个Session值,比如“当前用户:”+session ,并且点击页面上的链接时,状态栏上的内容不变。
- [求助]如何在知道Repter控件中是否有绑定的数据。
- 动态生成DataGird BoundColumn列 填充数据后怎么进行分页?
- VS2005 和VS2003 有什么区别?
//===================================================================
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
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 Demo_Database.Manage
{
/// <summary>
/// Summary description for admin_addManage.
/// </summary>
public class admin_addManage : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.CompareValidator CompareValidator1;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
protected System.Web.UI.WebControls.TextBox username;
protected System.Web.UI.WebControls.TextBox pass;
protected System.Web.UI.WebControls.TextBox pass2;
protected System.Web.UI.WebControls.Button cmdReg;
protected System.Web.UI.WebControls.Button cmdCancel;
protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
protected System.Web.UI.WebControls.Label Label1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
} #region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.cmdReg.Click += new System.EventHandler(this.cmdReg_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void cmdReg_Click(object sender, System.EventArgs e)
{
string uname=this.username.Text;
string pass=this.pass.Text;
if (checkUser(uname))
{
string mysql="insert into admin_manage (adminuser,adminpass) values('"+uname+"','"+pass+"')";
SqlCommand exec=new SqlCommand(mysql,Module.Connection.GetConnObj());
exec.ExecuteNonQuery();
Response.Write("新用户添加成功。");
}
}
private bool checkUser(string uname)
{
bool a;
string mysql="select * from admin_manage where adminuser='"+uname.ToLower() + "'";
SqlCommand exec=new SqlCommand(mysql,Module.Connection.GetConnObj());
SqlDataReader reader=exec.ExecuteReader();
if (!reader.HasRows)
{
Response.Write("ok。可以注册");
a=true;
}
else
{
Response.Write("Sorry.不允许注册该用户名,");
a=false;
}
return a;
}
}
}
//==================================================================================aspx//=================================================================================
<%@ Page language="c#" Codebehind="admin_addManage.aspx.cs" AutoEventWireup="false" Inherits="Demo_Database.Manage.admin_addManage" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>admin_addManage</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 64px; POSITION: absolute; TOP: 72px" runat="server"
Width="56px" Height="16px">用户名</asp:Label>
<asp:Label id="Label2" style="Z-INDEX: 102; LEFT: 64px; POSITION: absolute; TOP: 136px" runat="server">密码</asp:Label>
<asp:TextBox id="pass" style="Z-INDEX: 103; LEFT: 176px; POSITION: absolute; TOP: 104px" runat="server"
TextMode="Password"></asp:TextBox>
<asp:Label id="Label3" style="Z-INDEX: 104; LEFT: 64px; POSITION: absolute; TOP: 104px" runat="server">密码确认</asp:Label>
<asp:TextBox id="pass2" style="Z-INDEX: 105; LEFT: 176px; POSITION: absolute; TOP: 136px" runat="server"
TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator1" style="Z-INDEX: 106; LEFT: 360px; POSITION: absolute; TOP: 80px"
runat="server" ErrorMessage="用户名不能为空" ControlToValidate="username" Width="112px"></asp:RequiredFieldValidator>
<asp:CompareValidator id="CompareValidator1" style="Z-INDEX: 107; LEFT: 360px; POSITION: absolute; TOP: 144px"
runat="server" ErrorMessage="2次密码不同" ControlToValidate="pass2" ControlToCompare="pass"></asp:CompareValidator>
<asp:RequiredFieldValidator id="RequiredFieldValidator2" style="Z-INDEX: 108; LEFT: 360px; POSITION: absolute; TOP: 112px"
runat="server" ErrorMessage="请填写密码" ControlToValidate="pass"></asp:RequiredFieldValidator>
<asp:Button id="cmdReg" style="Z-INDEX: 109; LEFT: 160px; POSITION: absolute; TOP: 176px" runat="server"
Text="注册"></asp:Button>
<asp:Button id="cmdCancel" style="Z-INDEX: 110; LEFT: 216px; POSITION: absolute; TOP: 176px"
runat="server" Text="取消"></asp:Button>
<asp:TextBox id="username" runat="server" style="Z-INDEX: 111; LEFT: 176px; POSITION: absolute; TOP: 72px"></asp:TextBox>
<asp:RegularExpressionValidator id="RegularExpressionValidator1" style="Z-INDEX: 112; LEFT: 480px; POSITION: absolute; TOP: 80px"
runat="server" Width="96px" ControlToValidate="username" ErrorMessage="包含非法字符" ValidationExpression="\w+$"></asp:RegularExpressionValidator>
</FONT>
</form>
</body>
</HTML>
//==================================================================================
//*****验证用户是否重新ProcCreate Proc Proc_SystemUser_ExisitUser
(
@UserCode varchar(30),
@ExitsState smallint output --验证状态,如果返回值为1的得话则表示该用户己注册过
)
as
BEGIN
DECLARE @USEREXITS INT;
SELECT * FROM TB_SYSTEM_USER WHERE USERCODE=@USERCODE
IF(@@ROWCOUNT<=0)
BEGIN
SET @USEREXITS =1;
SET @ExitsState =@USEREXITS
END
ELSE
BEGIN
SET @USEREXITS=0;
SET @USEREXITS =@USEREXITS
END
END