There is a function in php login system which takes no arguments but returns IP Address of the user who is using system. get_client_ip(); function you can use this function in your project to get user ip address. The function to get user IP make sure you get client’s ip no matter which protocol he is using http or remote.
This function also get user’s real ip address if a user is trying to access your system from a proxy then this function can get you his/her real IP instead of proxy ip which makes things secure for us.