Here is a simple tutorial to display the visitors IP. You can also capture the IP and use it in other parts of your code.
<?php $user_ip = $SERVER['REMOTE_ADDR']; print "Your IP Address is " . $user_ip; ?>
The above lines of code grab the users IP address and display it. That is all there is to grabbing the users IP.