我在做登录页面 [英] i am doing login page
问题描述
首先我创建数据库并在数据库中手动输入值。
数据库字段如下; (表名测试)
登录ID 1
Firs tname ram
姓氏kumar
密码123
Lastlogin时间1.31 PM
然后我创建登录页面设计如下;
用户名文本框1
密码文本框2
运行中
模式我从表中输入用户名1和密码(测试)我手动创建我输入此登录页面的loginid和密码(运行模式)
当我输入用户名1和密码123.然后单击插入按钮我想显示消息有效登录名和密码。
假设我输入错误的用户名和密码我要显示消息无效登录和密码。
我是如何用c sharp在asp.net中编写代码的。它是Web应用程序项目。请帮助我
first i am creating database and enter the values manually in the database itself.
database fields as follows; (Table name test)
Login id 1
Firs tname ram
Last name kumar
Password 123
Lastlogin time 1.31 PM
Then i am creating the Login page design as follows;
Username textbox1
Password textbox2
in the run mode i type the username 1 and password from the table (test) i am creating manually that loginid and password i am typing to this loginpage(run mode)
when i type username 1 and password 123. and click the insert button i want to show the message valid loginid and password.
suppose i type wrong username and password i want to show the message invalid login and password.
for that i how to write the code in asp.net with c sharp. it is web application project. please help me
推荐答案
在asp.net中查看此登录教程,然后应用您的逻辑来完成其余的工作..
< a href =http://www.dotnetfunda.com/articles/article808-how-to-write-a-simple-login-page-in-aspnet.aspx> http://www.dotnetfunda.com/articles /article808-how-to-write-a-simple-login-page-in-aspnet.aspx [ ^ ]
http://www.developerscode.com/2011/02/how-to-create- login-page-in-aspnet-with.html [ ^ ]
See this login tutorial in asp.net and then apply your logic to do rest of the work..
http://www.dotnetfunda.com/articles/article808-how-to-write-a-simple-login-page-in-aspnet.aspx[^]
http://www.developerscode.com/2011/02/how-to-create-login-page-in-aspnet-with.html[^]
string SqlConnect = System.Configuration.ConfigurationManager.ConnectionStrings["Connect"].ConnectionString;
SqlConnection Sqlconn = new SqlConnection(SqlConnect);
SqlCommand sqlcomm = new SqlCommand("select email,userpassword from signup where email='" + TextBox1.Text + "' and userpassword='" + TextBox2.Text + "'",Sqlconn);
Sqlconn.Open();
SqlDataReader dr = sqlcomm.ExecuteReader();
if (dr.HasRows)
{
Session["email"] = TextBox1.Text;
dr.Close();
Sqlconn.Close();
Label1.Text = "Email-ID or Password you entered Is Valid !";
}
else
{
Label1.Text = "Email-ID or Password you entered do not match !";
Label1.ForeColor = System.Drawing.Color.DarkGreen;
}
protected void loginbtn_Click(object sender, EventArgs e)
{
string cmd = new "SELECT * FROM Users";
SqlDataAdapter da = new SqlDataAdapter(cmd,con);
DataTable dt = new DataTable();
da.Fill(dt);
string msg = "";
foreach(DataRow dr in dt.Rows)
{
if(unameTxt.Text == dr["username"].ToString() && pswdTxt.Text == dr["password"].ToString())
msg = "Success";
else
msg = "Error";
}
}
这篇关于我在做登录页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!