I need to pre-populate form with info based on the page where the user was referred from. The only identifier I can get from a URL of the previous page. Should I go with something like
if (ereg("item1",$_SERVER['HTTP_REFERER'])) { $myvar = 'item1'; }
Unfortunately it is not guaranteed to be reliable, but if that is the best you can do, then that is the best you can do.
Incidentally, prefer preg_match() to ereg(), but in this case a simple strpos() or stripos() will do.
I'll give it a whirl.
Note that if the page is on your own website, you could start a session and store the last page viewed in a session variable... that'd be more reliable than using the optional/easily-falsified "Referer" header.