protected void
btnlogin_Click(object sender, EventArgs e)
{
if (txtid.Text == "" || txtpswd.Text
== "")
{
Response.Write("");
}
else
{
string strname = txtid.Text;
string strpswd = txtpswd.Text;
OdbcConnection con = new
OdbcConnection("DRIVER={MySQL ODBC 3.51
Driver};SERVER=localhost;DATABASE=hdesk;uid=root;password=pssone;");
con.Open();
OdbcCommand cmd = new OdbcCommand("select
count(e_uid) from emp_mast where e_uid = '" + strname
+ "' and e_pswd =
'" + strpswd + "' and e_accept = 'Y'", con);
OdbcCommand cmd1 = new OdbcCommand("select
e_uid from emp_mast where e_uid = '" + strname +
"'", con);
if (Convert.ToInt32(cmd.ExecuteScalar().ToString()) > 0)
{
string uid =
cmd1.ExecuteScalar().ToString();
if (uid == "admin")
{
Session.Add("muser", txtid.Text);
Response.Redirect("AdminApproval.aspx");
}
else
{
Session.Add("muser", txtid.Text);
Response.Redirect("UserHome.aspx");
clearlist();
}
}
else
{
Response.Write("");
clearlist();
}
}
}
|
Raunak JhawarPosted Dec 31, 2009, 2:28 AM
//Code for Log out button
protected void Logout_Click(object sender, EventArgs e)
{
Session.Clear();
Session.Abandon();
Response.Redirect("Login.aspx");
}
//Code for page Load
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserID"] == null)
{
Response.Redirect("Login.aspx");
}
else
{
Label6.Text = Session["UserID"].ToString();
Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1d);
Response.Expires = -1500;
Response.CacheControl = "no-cache";
}
}
Purushottam RathorePosted Dec 31, 2009, 1:27 AM
Follow this link
http://www.c-sharpcorner.com/Forums/ShowMessages.aspx?ThreadID=73273