hi
i want to select username and password for only user who are confirmed from admin else alret message that it is still un confirmed this my code behind which i try
public bool Login(string user, string pass)
{
string sel = string.Format("SELECT * FROM Tbl_Users WHERE U_UserName ='{0}' and U_PassWord ='{1}'", user, pass);
DataTable tbl = Search(sel);
if ((tbl.Rows[13] = true) && tbl.Rows.Count == 1)
return true;
else
{
return flase;
}
}
the tbl.Rows[13] is for field index
protected void btnlogin_Click(object sender, EventArgs e)
{
Mem m = new Mem();
if (m.Login(txtuser.Text, txtpass.Text) == true)
{
utility.CreateCookie("login", new string[] {"U"},
new string[] {txtuser.Text}, ChkReM.Checked, Response);
Response.Write("");
Redirect(txtuser.Text);
}
else if (m.Login(txtuser.Text, txtpass.Text) == false)
{
// Response.Write("");
}
else
{
Response.Write("");
}
}
Loading
VulpesPosted Jun 19, 2014, 2:54 PM
VulpesPosted Jun 20, 2014, 12:13 PM
Consequently, the code in the 'else' clause in your btnlogin_Click handler will never run because the case when Login returns false will have already been dealt with by the 'else if' clause.
I'm not entirely clear what you're doing here but it would seem that both the username and password could be OK but the Login method could still return false because tbl.Rows[13] is false.
May be you need to return one of three values here (either an int = 1, 2 or 3 or an enum) rather than one of two values?
alaaPosted Jun 20, 2014, 3:24 AM