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.
|
|
|
 |
|