If you have tons of these login links (like a different one from every page on your site), you don't want Googlebot to crawl all the variations. That would be too much unnecessary crawling that could eat up the crawl budget for your site. Googlebot might not be able to crawl all the pages you want them to crawl and index. In that case, you should disallow the variants using robots.txt.
Including the question mark at the end of the disallow rule prevents Google from crawling any login link with URL parameters, but would allow crawling the version without parameters. Because Google won't be able to crawl them, Google won't index them unless a variation gets several external links.
The second thing that you can do is prevent Googlebot from finding the URLs with the parameters by appending the parameters dynamically using the
<a href=/login.php onclick="this.href+='?post_id=50'">Log in</a>
The third thing that you can do is include
/login.php in your XML sitemap but NOT
/login.php?post_id=50 or any other variants. When you include a URL in your sitemap, Google uses that as a signal that that version of the URL is the correct and important one that you want indexed.
The last option is to allow the URLs to be crawled, but use a canonical tag in the
<head> of the login page:
<link rel=canonical href=https://example.com/login.php>
This canonical tag would always point to the version of the login page without parameters. When Googlebot crawls a variation of the login page, it would find the canonical tag and know that you would prefer that the version without the parameter get indexed instead. Note that this solution is not compatible with the robots.txt solution. If Googlebot can't crawl the URL, it can't see this tag.