i have a relation about user details,when user click on forget and give registered mail it sends to that mail how to do this with checking mail is recorded or not with some more restrictions
help me
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kirtan PatelPosted Dec 26, 2009, 12:41 AM
Here I Coded How to Achieve that you want.
protected void btnResetPassword_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Your Connection String");
con.Open();
SqlCommand comm = new SqlCommand("select * from userDetail where email='" + txtMail.Text + "'", con);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(comm);
da.Fill(dt);
if (dt.Rows.Count > 0)
{
// Reset the password bu Updating the Password Field in Database
//Build Random Password for User to Send it in Mail
Random r = new Random();
string newPasword = "";
for (int i = 0; i <= 5; i++)
{
newPasword += r.Next(65, 90);
}
comm = new SqlCommand("update UserDetails set password='" + newPasword + "' where email='" + txtMail.Text + "'", con);
comm.ExecuteNonQuery();
con.Close();
// Now Send the New password to user By
//Code to Send mail Hope you know the code to send mail
}else
{
//Warn user that Email Not found In Database
Response.Write("Email Not found In Database!!");
}
}
sonal saxenaPosted Dec 26, 2009, 12:37 AM
thnks