aspx用户登陆程序
给钱!!!!!!!!!!
参考一下
//获取输入用户名和密码
Session["name"]=user.Text;
string password=pwd.Text ;
//连接SQL SERVER数据库
// myconnection=new System.Data.SqlClient.SqlConnection ("server=localhost;uid=sa;pwd=sa;database=zhltest");
// myconnection.Open() ;//连接数据库
com page =new com ();
myconnection=page.mycon1 ();
mycommand=new System.Data.SqlClient.SqlCommand ();
mycommand.Connection =myconnection;
mycommand.CommandText ="select * from test where username = '" +Session["name"]+ "'";
reader=mycommand.ExecuteReader ();
//判断该用户是否存在
if(reader.Read ()==false)
{
wel.Text =Session["name"]+"没有注册!";
return;
}
else if(reader.GetString(1) != CreatePasswordHash(password,reader.GetString (2)))
{
wel.Text ="密码错误!";
return;
}
else
{
string url="index.aspx?name="+user.Text +"&password="+CreatePasswordHash(password,reader.GetString (2)) ;
Response.Redirect (url);
}
参考一下
//获取输入用户名和密码
Session["name"]=user.Text;
string password=pwd.Text ;
//连接SQL SERVER数据库
// myconnection=new System.Data.SqlClient.SqlConnection ("server=localhost;uid=sa;pwd=sa;database=zhltest");
// myconnection.Open() ;//连接数据库
com page =new com ();
myconnection=page.mycon1 ();
mycommand=new System.Data.SqlClient.SqlCommand ();
mycommand.Connection =myconnection;
mycommand.CommandText ="select * from test where username = '" +Session["name"]+ "'";
reader=mycommand.ExecuteReader ();
//判断该用户是否存在
if(reader.Read ()==false)
{
wel.Text =Session["name"]+"没有注册!";
return;
}
else if(reader.GetString(1) != CreatePasswordHash(password,reader.GetString (2)))
{
wel.Text ="密码错误!";
return;
}
else
{
string url="index.aspx?name="+user.Text +"&password="+CreatePasswordHash(password,reader.GetString (2)) ;
Response.Redirect (url);
}