One way would be to add the product id to the URL for login.php when you do the redirect, then when the user logs in correctly, have your login script call the code to add the id into the wishlist. Obviously you’d need some checks on the id before just blindly storing it.
Another way might be to stick it in a session variable as a “pending adding to wishlist” product id, and have the login code check for that.
Basically you’re going to need to pass the product id into the login code somehow, and have that add it on successful login, there’s probably other ways of doing it.