注册登录界面
哪位大哥帮小弟写一个注册登录界面的源代码,只要很简单的就好。谢谢~ --------------------编程问答-------------------- 要注册又要登录?????网上有很多这样的源代码吧 --------------------编程问答-------------------- 没说明白 都是注册哪些字段啊 --------------------编程问答-------------------- 网上多的是啊,这个不会写的话 很杯具。。。。。。。 --------------------编程问答-------------------- 用vs2008可以直接拖个控件出来..基本就搞定了. --------------------编程问答-------------------- 网上很多嘛,VS也有自带的控件呀 --------------------编程问答-------------------- 在网上找吧,好像任意一个都带这两个功能,要是把它们合到一起,咱还真不知道,楼主知道拿到了,贴出来,也让俺学学,谢谢…… --------------------编程问答-------------------- 杯具杯具杯具 --------------------编程问答-------------------- Ajax的protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection sqlcon;
string strCon = "Data Source=(local);Database=BooksManage;Uid=sa;Pwd=xxx5354";
try
{
if ((!(TextBox1.Text.ToString() == "")) && (!(TextBox2.Text.ToString() == "")))
{
string username = TextBox1.Text.ToString().Replace(" ", "");
string pwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox2.Text.ToString().Replace(" ", ""), "MD5").ToString();//密码加密
string sqlstr = "select * from adminuser where name=" + "'" + username + "'" + " and password=" + "'" + pwd + "'";
sqlcon = new SqlConnection(strCon);
SqlDataAdapter myda = new SqlDataAdapter(sqlstr, sqlcon);
DataSet myds = new DataSet();
sqlcon.Open();
myda.Fill(myds, "adminuser");
sqlcon.Close();
if (myds.Tables[0].Rows.Count == 1)
{
Session["username"] = username;
Session["type"] = myds.Tables["adminuser"].Rows[0]["rank"].ToString();
Session["user_id"] = myds.Tables["adminuser"].Rows[0]["id"].ToString();
Response.Redirect("~/aspx/BooksManage.aspx");
}
else
{
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "alert", "<script language='javascript'>alert('提示\\n用户名或密码不正确!');document.all('TextBox1').focus()</script>", false);
}
}
else
{
if (TextBox1.Text.ToString() == "")
{
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "alert", "<script language='javascript'>alert('用户名不能为空!');document.all('TextBox1').focus()</script>", false);
}
if (TextBox2.Text.ToString() == "")
{
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "alert", "<script language='javascript'>alert('密码不能为空!');document.all('TextBox2').focus()</script>", false);
}
}
}
catch (System.NullReferenceException er)
{
Label1.Text = er.Message;
}
} --------------------编程问答-------------------- 我给你代码,你告诉我邮箱什么的 --------------------编程问答--------------------
是的啊。 --------------------编程问答-------------------- 楼主不会是先要登录注册,然后又要文章系统、留言板、。。。。??? --------------------编程问答-------------------- <%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Security" %>
<script runat="server">
public void CreateUser_OnClick(object sender, EventArgs args)
{
MembershipCreateStatus result;
try
{
// Create new user.
if (Membership.RequiresQuestionAndAnswer)
{
MembershipUser newUser = Membership.CreateUser(
UsernameTextbox.Text,
PasswordTextbox.Text,
EmailTextbox.Text,
PasswordQuestionTextbox.Text,
PasswordAnswerTextbox.Text,
false,
out result);
}
else
{
MembershipUser newUser = Membership.CreateUser(
UsernameTextbox.Text,
PasswordTextbox.Text,
EmailTextbox.Text);
}
Response.Redirect("login.aspx");
}
catch (MembershipCreateUserException e)
{
Msg.Text = GetErrorMessage(e.StatusCode);
}
catch (HttpException e)
{
Msg.Text = e.Message;
}
}
public string GetErrorMessage(MembershipCreateStatus status)
{
switch (status)
{
case MembershipCreateStatus.DuplicateUserName:
return "Username already exists. Please enter a different user name.";
case MembershipCreateStatus.DuplicateEmail:
return "A username for that e-mail address already exists. Please enter a different e-mail address.";
case MembershipCreateStatus.InvalidPassword:
return "The password provided is invalid. Please enter a valid password value.";
case MembershipCreateStatus.InvalidEmail:
return "The e-mail address provided is invalid. Please check the value and try again.";
case MembershipCreateStatus.InvalidAnswer:
return "The password retrieval answer provided is invalid. Please check the value and try again.";
case MembershipCreateStatus.InvalidQuestion:
return "The password retrieval question provided is invalid. Please check the value and try again.";
case MembershipCreateStatus.InvalidUserName:
return "The user name provided is invalid. Please check the value and try again.";
case MembershipCreateStatus.ProviderError:
return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
case MembershipCreateStatus.UserRejected:
return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
default:
return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
}
}
</script>
<html>
<head>
<title>Create User</title>
</head>
<body>
<form runat="server">
<h3>Create New User</h3>
<asp:Label id="Msg" ForeColor="maroon" runat="server" /><BR>
<table CellPadding="3" border="0">
<tr>
<td>Username:</td>
<td><asp:Textbox id="UsernameTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="UsernameRequiredValidator" runat="server"
ControlToValidate="UserNameTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td>Password:</td>
<td><asp:Textbox id="PasswordTextbox" runat="server" TextMode="Password" /></td>
<td><asp:RequiredFieldValidator id="PasswordRequiredValidator" runat="server"
ControlToValidate="PasswordTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td>Confirm Password:</td>
<td><asp:Textbox id="PasswordConfirmTextbox" runat="server" TextMode="Password" /></td>
<td><asp:RequiredFieldValidator id="PasswordConfirmRequiredValidator" runat="server"
ControlToValidate="PasswordConfirmTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" />
<asp:CompareValidator id="PasswordConfirmCompareValidator" runat="server"
ControlToValidate="PasswordConfirmTextbox" ForeColor="red"
Display="Static" ControlToCompare="PasswordTextBox"
ErrorMessage="Confirm password must match password." />
</td>
</tr>
<tr>
<td>Email Address:</td>
<td><asp:Textbox id="EmailTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="EmailRequiredValidator" runat="server"
ControlToValidate="EmailTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<% if (Membership.RequiresQuestionAndAnswer) { %>
<tr>
<td>Password Question:</td>
<td><asp:Textbox id="PasswordQuestionTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="PasswordQuestionRequiredValidator" runat="server"
ControlToValidate="PasswordQuestionTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td>Password Answer:</td>
<td><asp:Textbox id="PasswordAnswerTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="PasswordAnswerRequiredValidator" runat="server"
ControlToValidate="PasswordAnswerTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<% } %>
<tr>
<td></td>
<td><asp:Button id="CreateUserButton" Text="Create User" OnClick="CreateUser_OnClick" runat="server" /></td>
</tr>
</table>
</form>
</body>
</html> --------------------编程问答-------------------- 有没有扫盲教的呀?!~ --------------------编程问答-------------------- 。。。。跑到这上面 来要这种东西。。 你让我怎么说!!!
补充:.NET技术 , ASP.NET