CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> CodeChargeStudio.Discussion

 Grabbing a users IP with PHP

Print topic Send  topic

Author Message
Kevin
Posted: 01/20/2003, 11:15 AM

I ran into a problem with different versions of PHP in retrieving
REMOTE_ADDR and came up with this fix;

Put this in the top of your php code below the existing includes

include(RelativePath . "/GetIP.php");

-----------
Save the below to GetIP.php
-------------------
<?php
function GetIP() {
$server_var = $_SERVER["REMOTE_ADDR"];
$http_var = $HTTP_SERVER_VARS['REMOTE_ADDR'];
if ($server_var) {$ip_add = $server_var;}
elseif ($http_var) {$ip_add = $http_var;}
else {$ip_add = "Invaild IP Address";}
return $ip_add;
}
?>

This assumes your database table has a field called ip_address of type
text(access)/varchar(mySQL)/varchar2(Oracle) width 19

Create a record grid adding the ip_address field to the grid as a hidden
field,
in the design view click on the ip_address field and add GetIP() as the
Default value,
mark the ip_address field as Required.
Now every time the page is submitted the ip_address field will be updated
with an IP address regardless
of the PHP version.


   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.