Welcome to WebmasterWorld Guest from 18.104.22.168
How difficult will this be if at all possible?
Get the referrer using $HTTP_REFERER
use the ereg() function to check for a search engine
use ereg_replace() or preg_replace() to parse out the keywords
The biggest problem can be finding the right regex to use to get the keywords out of the referral string, but the actual script would be fairly straightforward.