Jump to content

storing and retv ipaddress?


desjardins2010

Recommended Posts

hey all;

 

I had a post in here I was getting help with and I can't figure out how to search for all my post so for that i apologize...

 

I'm needing to give a user an ip address prob is when I try to store in the the database it don't store.. it cuts it?

 

anyone help on how to do this and be able to refer to it per user

Link to comment
Share on other sites

hey all;

 

I had a post in here I was getting help with and I can't figure out how to search for all my post so for that i apologize...

 

I'm needing to give a user an ip address prob is when I try to store in the the database it don't store.. it cuts it?

 

anyone help on how to do this and be able to refer to it per user

 

This script works, I didnt write it but I have used it successfully to store ip addresses

$ip = getRealIpAddr();

function getRealIpAddr() 
{ 
    if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet 
    { 
      $ip=$_SERVER['HTTP_CLIENT_IP']; 
    } 
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy 
    { 
      $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; 
    } 
    else 
    { 
      $ip=$_SERVER['REMOTE_ADDR']; 
    } 
    return $ip; 
} 

 

Link to comment
Share on other sites

ya thats using there real IP address what I'm trying to accomplish is when a user registers for the game they are given a random IP address, this ip address is stored in the database under a field IPaddress, later I want to be able to SELECT the user if there IP address matches the one entered into a form...

 

so really just a way of given a user a random ip address on register as a feild that is INSERTED into the database when they register and then being able to reference that IP address later...

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.