302 Found is a redirection response, it likely means the login attempt worked and the website is redirecting you to the next page. You should follow the redirection by making a request to the
URL provide by the Location header.
A 403 response is an authorization issue, which likely means the password was wrong.
Both responses are expected in their respective scenarios.
The tl;dr of this is that there's much more to logging into a website than submitting a single form. Your script has to handle redirects and cookies the way a regular web browser would be expected to.