# Detecting IP-address

**URL:** <https://forum.kirupa.com/t/detecting-ip-address/20766>\
**Category:** flash\
**Created:** [May 13, 2003, 8:31am UTC](https://forum.kirupa.com/t/detecting-ip-address/20766 "2003-05-13T08:31:36Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikini](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/nikini/32/225_2.png) [@Nikini](https://forum.kirupa.com/u/Nikini)\
**Post date:** [May 13, 2003, 8:31am UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/1 "2003-05-13T08:31:36Z")

</div>

:cool: How do i detect the IP address of the one that’s visiting my web-site? Is there a way? Please help

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 13, 2003, 8:43am UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/2 "2003-05-13T08:43:13Z")

</div>

you can’t do it in flash on its own, you’ll need a little PHP or ASP.  
With php the command is:

$HTTP\_SERVER\_VARS[“REMOTE\_ADDR”]

let me know if you need more info

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 13, 2003, 8:58am UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/3 "2003-05-13T08:58:27Z")

</div>

What’s the differnce from the loadSound(path,value)? If value is true or false? Does it make a differnece and what is the most reccomended on the internet?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 13, 2003, 9:03am UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/4 "2003-05-13T09:03:32Z")

</div>

if you have value set to true, the sound you load will stream. That is the sound will begin playing before it has finished loading. If you have the value set to false flash waits for the sound to load completely before it begins playing it.

Its useful to have it set to true for large/long sounds as you won’t have to wait ages while the whole file is downloaded for it to begin playing

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 13, 2003, 9:11am UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/5 "2003-05-13T09:11:41Z")

</div>

Thanks a lot for everything, and are you sure there’s no way of detecting the Ip-address in Flash MX?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 13, 2003, 9:12am UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/6 "2003-05-13T09:12:33Z")

</div>

yeah 100% sure :nerd:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 13, 2003, 9:15am UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/7 "2003-05-13T09:15:41Z")

</div>

Ok, thanks, but i don’t have PHP where can i get it?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 13, 2003, 9:24am UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/8 "2003-05-13T09:24:53Z")

</div>

PHP is a free language, but it isn’t much good to you as it needs to be installed on your server. Check with your site hosts to find out if they have it installed on your server. Anyone can write a php script, all you need to do is create a new textfile and change its extension from .txt to .php and then open it up in notepad or similar. This is the php script that’ll return a users IP for you:

```php

<?

print "IP=$HTTP_SERVER_VARS["REMOTE_ADDR"]";

?>

```

save this to a file called IPReturn.php

if you create a new flash movie with a dynamic textfield on the stage with variable named ‘IP’. In the first frame put:  
this.loadVariables(“IPReturn.php”);

now if you upload your movie and php script to a web server with php installed when you access the movie it’ll display your IP address in the dynamic textfield

if you want an introduction to php try posting in the Server-Side/Scripting forum for expert advice

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 13, 2003, 9:30am UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/9 "2003-05-13T09:30:13Z")

</div>

Thanks a lot, when i finish my web site- in about a month, please come: www.NikiniWebDesign.go.ro, it will be made in flash mx, aniway, now, can you please help me on how to save that ip into a text file and later to check for it in the same text file

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 13, 2003, 9:36am UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/10 "2003-05-13T09:36:24Z")

</div>

you can save ip’s to a textfile with php. This is the script to do it:

\<?  
$filename = “Log.txt”;  
$fp = fopen($filename, “a”);  
$IP = $\_SERVER[“REMOTE\_ADDR”];  
$DateStamp = date(“F j, Y, g:i a”);  
$Log = $HTTP\_SERVER\_VARS[“REMOTE\_ADDR”] . " visited on " . $DateStamp . "  
";  
fputs($fp, $Log);  
fclose($fp);  
?\>

which saves each visitors IP and the date and time (according to the server) to a text file called Log.txt, to run this script from flash you’d use loadVariables or loadVariablesNum as before

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 13, 2003, 9:40am UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/11 "2003-05-13T09:40:06Z")

</div>

Ok, thanks a lot, now please tell me how do i check if an ip has came before? and if you please, can you please tell me the whole code to write and where to write?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 13, 2003, 9:52am UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/12 "2003-05-13T09:52:05Z")

</div>

there’s an easier way to detect if someone has visited before, and that is to use a sharedObject which works like a cookie, saving a small file on the users computer.

Put this script in the first frame of your movie:

```auto

Cookie = sharedObject.getLocal("VisitCheck");
if(Cookie.data.Check) {
      // this code is executed on revisiting the site
}else {
      // this code is executed on the first visit
}
_root.Cookie.data.Check = true;
_root.Cookie.flush();

```

hope this helps

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 13, 2003, 9:54am UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/13 "2003-05-13T09:54:56Z")

</div>

You have just become my best friend, thanks a lot…, if you need some help and i can possibly help you then tell me how…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 13, 2003, 9:56am UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/14 "2003-05-13T09:56:03Z")

</div>

heh heh, no problem  
glad I could be a help 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 13, 2003, 10:09am UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/15 "2003-05-13T10:09:18Z")

</div>

God, thanks a lot, i tested the code, and it works, how can i save for the new users a name and if they visit again they already have a name

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 13, 2003, 10:17am UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/16 "2003-05-13T10:17:40Z")

</div>

you can save anything you like to the sharedObject, all data is accessed through the data method:

if you had a variable ‘Name’ that the user has entered their name into you would save it to the cookie like this:

```auto

// note the cookie has already been loaded using
// Cookie = sharedObject.getLocal("VisitCheck");
Cookie.data.Name = Name;

```

and recalling it is just as easy:

```auto

SavedName = Cookie.data.Name;

```

if no name has been saved SavedName will be set to undefined

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 15, 2003, 9:55pm UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/17 "2003-05-15T21:55:51Z")

</div>

sorry, when I do what you has said, the php file doesn’t work --\> the flash file doen’t work too

It erro:  
Parse error: parse error, unexpected ‘"’, expecting T\_STRING or T\_VARIABLE or T\_NUM\_STRING in /usr/local/psa/home/vhosts/u2u.us/httpdocs/portal/counter.php on line

[http://www.u2u.us/portal/counter.php](http://www.u2u.us/portal/counter.php)

how do I fix it ? thanks

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 1:35pm UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/18 "2003-05-18T13:35:09Z")

</div>

ok, well the php really doen not work, it’s true, but the flash thing works, really does…but i’m till searching for a method to detect the ip address directly from flash, there simply has to be a way… i think

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 6:30pm UTC](https://forum.kirupa.com/t/detecting-ip-address/20766/19 "2003-05-18T18:30:18Z")

</div>

hix, it doesn’t work too, [http://www.u2u.us/portal/counter.swf](http://www.u2u.us/portal/counter.swf)  
can I get your sample source please ?
