CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> Archive -> GotoCode Archive

 capturing the users ip address (remote_addr)

Print topic Send  topic

Author Message
Janice Scott
Posted: 05/16/2002, 7:44 PM

I am using the example 'portal' in php4 and I want to automatically trap the user's ip when someone registers a new user. The field: ip_insert was in the sample database but there was no user code to fill it. I used the following:

$fldip_insert=$HTTP_SERVER_VARS['REMOTE_ADDR'];

I tried to insert this in the 'before insert' and 'before show insert' but it doesn't seem to work in either place. It will echo in a simple php script on my server.

<?php
echo $HTTP_SERVER_VARS['REMOTE_ADDR'];
?>

So I know the function is avaliable but I can't get it to work in cc. Can anyone tell me how to do this.

Janice
Brent
Posted: 05/16/2002, 8:09 PM

I bet you forgot to issue a

global $HTTP_SERVER_VARS

before you started using it. :)
janice Scott
Posted: 05/17/2002, 6:49 AM

I originally did not have a global declaration because I assummed that system VARS were naturally global. I'm not sure where the global declaration should be. I tried to call it just prior to the remote_addr assign but that didn't work. I also tried to put the global declaration at the page 'on-open' but that didn't work either. Does the global declaration have to be in the common or is there a better place I can call it.

Thanks

Janice
Brent
Posted: 05/17/2002, 8:25 PM

Yes, the $HTTP_SERVER_VARS are global, but like all global variables, if you
reference them inside a function, you need to use a Global statement inside
your function. This example may clear things up.

<?PHP
function GetIPAddress()
{
global $HTTP_SERVER_VARS;
return $HTTP_SERVER_VARS['REMOTE_ADDR'];
}

echo "IP Address:".GetIPAddress();
?>
Janice Scott
Posted: 05/19/2002, 10:29 AM

Making a function of it worked just fine.

Thank you so much,

Janice
Johnny
Posted: 07/10/2003, 12:57 PM

How do i do this using ASP?

   


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

Web Database

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.