2013-04-29 58 views
-1

我需要一个代码,我可以使用这个代码在网站上创建一个页面,然后通过登录进行身份验证,这意味着我希望只有特定用户登录时才能访问该页面。 任何人都可以帮助我。登录后在网站上创建一个页面

(注意:是一个精简的,还是一个新手)

在此先感谢

+0

你有一个包含登录credenentials – 2013-04-29 12:32:03

+1

欢迎,因此任何数据库表。请阅读[常见问题] – Liam 2013-04-29 12:32:47

+0

是的,我有它@Rajeev库马尔 – 2013-04-29 12:33:54

回答

0

然后一个非常简单的PROGRAMM我写ü

readonly SqlConnection sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["VerbaLinksConString"].ToString()); 

try 
{ 
    SqlCommand cmd = new SqlCommand("Select txt_Password from table where txt_user_name = '"+txtUserName.Text+"' and txt_Pwd = '"+txtPassword.Text+"'",sqlCon); 
    sqlCon.Open(); 
    SqlDataReader dr = cmd.ExecuteReader(); 
    If(dr.Read()) 
    { 
    Response.Redirect("HomePage.aspx"); 
    } 
    else 
    { 
    Response.Write("Either userId or Password is wrong"); 
    } 
    SqlCon.Close(); 
} 
Catch(SqlException ex) 
{ 

} 
+0

谢谢你真的很感激它,它的工作就是我想要的方式! :-) – 2013-04-29 12:50:13

+0

一旦用户已经登录,是否也可以访问另一个页面? – 2013-04-29 12:59:52

+0

无法得到你想知道的! – 2013-04-30 03:05:49

相关问题