You could use the referer header (note that it's "REFERER" not "REFERRER" in the $_SERVER array); but as rownparker said it's easily faked AND not all servers will send them.
The random token might help, except that too can easily be faked. What you could do is use an encryption method ([man]mcrypt[/man]) and encrypt the url and store that as a hidden field on page1.php. Then on page2.php decrypt it. If that decrypted line doesn't have the URL you want in it, then deny it.
Also, in order to make it look "random" so that a hacker doesn't get the bright idea to try and guess at your encryption, try prepending it with the current time, and appending the URL with the time. That way the beginning and end always changes.