0 please give me the code for this one
0
If your 3-tire architecture is something like UI - Service - Database. Where UI talks to service and service talks to database, you may follow below steps:
1. Have forgot password method in your service.
2. Generate new password on your forgot password method and save it in database (you may have some encryption logic for password).
3. If new password is saved successfully on database, return new password to your UI calling method (you may still have password encrypted as it is traveling between service call).
4. Once you have new password returned from service (forgot password) call, email it to end user (if password was encrypted you may decrypt it before sending email).
Let me know if you have any question on this.