Thats true actually. Well i will be implementing the password recovery.
When users register to the site they also provide their security question and answer as i am encrypting the passwords using md5…
So the logic for this would be to select the answer from the database and if it matches the database then i can take users to a page where they reset their password?
This is my code:-
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "";
SqlConnection conn;
SqlCommand cmd;
SqlDataReader myReader;
string cmdString = "SELECT [answer] FROM hussaini_users WHERE [answer] = @answer";
conn = new SqlConnection("Data Source=SQLB23.webcontrolcenter.com;User ID=wbsd;Password=******");
cmd = new SqlCommand(cmdString, conn);
cmd.Parameters.Add("@answer", SqlDbType.Char).Value = TextBox1.Text;
conn.Open();
myReader = cmd.ExecuteReader();
if (myReader.Read())
{
if (myReader["answer"].ToString() == TextBox1.Text)
{
Label1.Text = "**EXISTS";
}
else
{
Label1.Text = "**DOES NOT EXIST";
}
}
}
This does not work either, no error message nothing. Am i doing something wrong?
Its hard to say, but if nothing is happening I assume the query is returning nothing. Put an else of the if(myReader.Read()) { }. Set the label to no data or something. Then the next step would be to set a break point and see what exactly the query is executing to make sure its right