If I understand your problem, you have two pages. The first page, which I will call login.php, has a form where users enter their user ID and password. This form is submitted to a second page, which I will call authenticate.php. This page looks for the user in the database. Then it shows a link to the first page, something like this: <a href="login.php">Login Page</a>.
Sessions might be a good solution for you. You can put the user id in a session variable. Then all pages can read it.
If you only have those two pages, you can change the link in authenticate.php to this: <a href="login.php?userid=<?php echo $id;?>">Login Page</a>. This will pass the user ID ($id) back to login.php.