In other words, how can I tell if the person using my web application is on the server it resides on? If I remember correctly, PHPMyAdmin does something like this for securi
$_SERVER["REMOTE_ADDR"]
should tell you the user's IP. It's spoofable, though.
Check this bounty question for a very detailed discussion.
I think what you remember with PHPMyAdmin is something different: Many MySQL Servers are configured so that they can only be accessed from localhost for security reasons.