One thing I see that could cause this page to not work is if you use the enter key to submit the form.
the enter key will press the first button on the page. On this page, the first button is the login button which will send you to the login page.
You have the email behavior set to send the user to the emailpwsent.php page. When it doesnt work, is the user going to that page or the login page?
When it doesnt work, what exact does happen?
Does the users password update in the database, but the email does not send, and the user is sent to the emailpwsent.php page?
Does the password update fail, the email fail and the user is directed to the login page?
or does the password update fail, the email fail and the user is directed to the emailpwsent.php page?