Hi dear,
You must tell me more details, like are you using wordpress?? if you are, you must use hook on your wordpress!
or are these database on the same database or not?
This answer help me to found your situation to fix your issue...
however without this details, now i can provide 2 ajax request for your databases,
otherwise i prefer to use password_hash() instead of sha1, because sha1 is not secure at this time!
just chat me for discussion about contract and details