Sorry for not being clear - but there's 2 things going on here and I want to try and fix both of them.
http://www.xxxxxx.com/article.php?id=12345
if that id doesn't pull a page from the database, then I can grab that query ID and sink it into an invisible tag and submit it with the form. So that part's easy.
But the second part of the problem is this: the entire website is migrating from a static site to a new database driven site. So if there are actually dead links embeded in the HTML of the old site (now a part of the database), I want to capture the page that is referring people to pages which are now not existent.
So http://www.xxxxxx.com/myfolder/myfile.htm is no longer a real page. Instead it's become article.php?id=10332848 or something like that. So when people go to the former link, they'll be redirected to a page which by which I want to capture (somehow) the page that sent them to the bad link. I hope that makes sense.