Well the main logic behind forgot password is like below
generally you need to check the unique value to retrive the password. like username / email id. when user enter this you check that value in Database. if that value exists in the database you will provide them the origional passoword or even you can reset the password and send it to them.
string Emailaddress = "abc@gmail.com";
string Query = "select * from tbl_user where username = Emailaddress";
if(Row > 0)
{
Record found (write your logic here);
}
else
{
No record found (write your logic here);
}