Member Avatar for kirtan_thakkar

I want to get details of user when he registers with my website for security reasons. I need ip and date and time I guess. Is there anything else I need to cache while registering? How to get ip,time and date? And time will be in which timezone? I want it in GMT +5:30 means asia - culcutta. Thanks in advance.

And i want to save user log in time. Any help about this will be thankful.

$IP = $_SERVER['REMOTE_ADDR'];
$date_time = date("l j F Y  g:ia", time() - date("Z")) ;
echo "$date_time   IP: $IP";

The $_SERVER superglobals provide a load of useful information.

$ip = $_SERVER['REMOTE_ADDR'];     // The IP address from which the user is viewing the current page.
$time = $_SERVER['REQUEST_TIME'];  // The timestamp of the start of the request.     
$port = $_SERVER['REMOTE_PORT'];   // The port being used on the user's machine to communicate with the web server.   
$browser = $_SERVER['HTTP_USER_AGENT']; // Contents of the User-Agent (Web browser): header from the current request

// etc...

See here

Hi

Use this to see what information can be accessed and then decide what you want to use and access it like any other array

foreach ($_SERVER as $key => $item)
 {
  echo "<li><b>$key:</b> $item<br/></li>";
 }

N

Member Avatar for kirtan_thakkar

Thank you all. It done my work. But I have a last question. What would be better format to store user's login time? Like 1296143233 or Thursday 27 January 2011 3:47pm? Thank you. And how to convert 1296143233 to Thursday 27 January 2011 3:47pm. I think first format will save the disk space. Please help.

I generally tend to use a Unix timestamp, but I'm not really sure what the 'best' format is. This link explains mysql date formats

You can convert a unix timestamp to a human-readable format using the date() function. You can format the date format to your liking:

$timestamp = 1296143233;
$formattedtime = date("d/m/y", $timestamp)

Or to turn a date back into a timestamp, use strtotime():

$date = "01/01/1970";
$date2timestamp = strtotime($date);
Member Avatar for kirtan_thakkar

Hey thanks.... My work will get done by this.. Thank you so much to all of you who helped......

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.