rajitha b

rajitha b

  • NA
  • 1
  • 0

about login

Aug 29 2008 4:35 AM

hai,
can you tell me where to place this if condition so that i can check both captcha image text and uname,pwd checking.
but if i gave both conditions it only checks uname,pwd,it doesn't checks captcha image text after giving wrong uname,pwd for 3 times.
here is the if condition for checking captcha text.
-------------------------------------------------------
// if (CodeNumberTextBox.Text == Session["CaptchaImageText"].ToString())
--------------------------------------------------------------

protected void Button1_Click(object sender, EventArgs e)
{
// On a postback, check the user input.

SqlConnection con = new SqlConnection("initial catalog=rajitha;data source=sys01;user id=sa");
con.Open();
// SqlDataReader dr = null;
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "select username,password from tb_login where username='" + TextBox1.Text + "' and password='" + TextBox2.Text + "'";//where Emailid='" + TextBox1.Text + "' and password='" + TextBox2.Text + "'";
cmd.CommandType = CommandType.Text;
SqlDataReader dr = cmd.ExecuteReader();
string un = TextBox1.Text;
string pd = TextBox2.Text;
// if (dr.HasRows)
// {

if (dr.Read())
{
string uname = dr["username"].ToString();
string pwd = dr["password"].ToString();
//
if (un == uname && pd ==pwd)

Server.Transfer("Default2.aspx");
return;
// if (CodeNumberTextBox.Text == Session["CaptchaImageText"].ToString())

}
else
{
Response.Write("you have entered incorrect user name,password");
// label3.Text = "you have entered incorrect username,password";
a = a + 1;

if (a > 2)
{
CodeNumberTextBox.Text = "";
Session["CaptchaImageText"] = GenerateRandomCode();

lb1.Visible = true;
lb2.Visible = true;
lb3.Visible = true;
CodeNumberTextBox.Visible = true;
rfd.Visible = true;
img1.Visible = true;
}

}
con.Close();


}


Answers (1)