Log in

View Full Version : Show a computers IP with HTML?



Meti
28-01-2009, 08:28 PM
Hey,
Is this possible? I think I had this before, but forgot code.
Example: On a contact form, it would show the persons IP number saying like:
"your IP Number will be sent with the email" etc.

++REP for help.

Hitman
28-01-2009, 08:32 PM
If I can remember correctly, you can't do it. HTML is client side and doesn't have anything to do with the server (it's just a page on the server). You can use PHP though.

Pazza
28-01-2009, 08:35 PM
<script language="JavaScript">
VIH_BackColor = "palegreen";
VIH_ForeColor = "navy";
VIH_FontPix = "16";
VIH_DisplayFormat = "You are visiting from:<br>IP Address: %%IP%%<br>Host: %%HOST%%";
VIH_DisplayOnPage = "yes";
</script>
<script language="JavaScript" src="http://scripts.hashemian.com/js/visitorIPHOST.js.php"></script>

Just edit that, and you should be done.

URL = http://www.hashemian.com/tools/visitor-IP.htm

But, there is a much simpler one here http://www.wallpaperama.com/forums/how-to-display-ip-address-php-script-code-function-from-visitor-user-t399.html

Meti
28-01-2009, 08:36 PM
Thanks,
++++++++rep lol :)

Mounta1nGoat
28-01-2009, 08:37 PM
If it's on a contact form chances are it's PHP.

Excellent2
28-01-2009, 09:08 PM
<?php

$ip = $_SERVER['REMOTE_ADDR'];

echo ('Your IP is: <br />$ip');

?>

DeejayMachoo$
28-01-2009, 09:47 PM
<?php

$ip = $_SERVER['REMOTE_ADDR'];

echo ('Your IP is: <br />$ip');

?>

Do u mean


<?php

$ip = $_SERVER['REMOTE_ADDR'];

echo ('Your IP is: <br />'.$ip);

?> or


<?php

$ip = $_SERVER['REMOTE_ADDR'];

echo "'Your IP is: <br />$ip");

?>

Excellent2
28-01-2009, 09:53 PM
Do u mean


<?php

$ip = $_SERVER['REMOTE_ADDR'];

echo ('Your IP is: <br />'.$ip);

?> or


<?php

$ip = $_SERVER['REMOTE_ADDR'];

echo "'Your IP is: <br />$ip");

?>No. I mean

<?php

$ip = $_SERVER['REMOTE_ADDR'];

echo ('Your IP is: <br />$ip');

?>

Trinity
28-01-2009, 10:51 PM
No. I mean

<?php

$ip = $_SERVER['REMOTE_ADDR'];

echo ('Your IP is: <br />$ip');

?>

But that wouldn't work bbz, single quotes.

--ss--
28-01-2009, 10:54 PM
Possible via Javascript:

var ip = '<!--#echo var="REMOTE_ADDR"-->';
either use document.write or use a popup to display it ;).

Iszak
28-01-2009, 11:01 PM
Use the PHP one because some people have javascript disabled.

iUnknown
28-01-2009, 11:04 PM
You can use either javascript/php.

Personally, I would go for PHP. Simply renaming the page to .php and adding a little code (I'd do it like this):



<?php
$ip = $_SERVER['REMOTE_ADDR'];
echo "<i>Your IP address has been logged: " . $ip . ".</i>";
?>
That would appear something like this:


Your IP address has been logged: 11.22.33.44

And could simply be put at the bottom of the form.

You can also simply add this to the area of the form coding that stores the data submitted in the form as variables (if PHP):


$ip = $_SERVER['REMOTE_ADDR']; And this would register the visitor's ip as a variable ($ip), and if it's something like submitting an email, you just add it to the email like all the other variables ie. name etc.

Hope I've helped.

Protege
29-01-2009, 05:41 AM
If I can remember correctly, you can't do it. HTML is client side and doesn't have anything to do with the server (it's just a page on the server). You can use PHP though.


Arent we trying to get the "clients" IP?

Javascript is also client side (though you can still get the IP with it), though I think it might be because
HTML is a markup language...??????????????????????????

Agnostic Bear
29-01-2009, 08:19 AM
why not just



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


instead of adding all your wacky YOUR IP IS" . $IP OH GOD SET A VARIABLE FOR SOMETHING THAT NEVER CHANGES

DeejayMachoo$
29-01-2009, 11:49 AM
why not just



<?php echo $_SERVER[ 'REMOTE_ADDR' ]; ?>
instead of adding all your wacky YOUR IP IS" . $IP OH GOD SET A VARIABLE FOR SOMETHING THAT NEVER CHANGES

So true ;) made me lol +rep

Meti
29-01-2009, 01:49 PM
<?php

$ip = $_SERVER['REMOTE_ADDR'];

echo ('Your IP is: <br />$ip');

?>
+REP IF I CAN


Possible via Javascript:

var ip = '<!--#echo var="REMOTE_ADDR"-->';
either use document.write or use a popup to display it ;).
+REP IF I CAN


You can use either javascript/php.

Personally, I would go for PHP. Simply renaming the page to .php and adding a little code (I'd do it like this):



<?php
$ip = $_SERVER['REMOTE_ADDR'];
echo "<i>Your IP address has been logged: " . $ip . ".</i>";
?>
That would appear something like this:


Your IP address has been logged: 11.22.33.44

And could simply be put at the bottom of the form.

You can also simply add this to the area of the form coding that stores the data submitted in the form as variables (if PHP):


$ip = $_SERVER['REMOTE_ADDR']; And this would register the visitor's ip as a variable ($ip), and if it's something like submitting an email, you just add it to the email like all the other variables ie. name etc.

Hope I've helped.

THANKS, +REP IF I CAN


why not just



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


instead of adding all your wacky YOUR IP IS" . $IP OH GOD SET A VARIABLE FOR SOMETHING THAT NEVER CHANGES
:O:O Thanks, +REP IF I CAN :)

Jahova
29-01-2009, 03:52 PM
Rofl, Jewish Bear makes me laugh every time. I'm loving the use of wacky. Anyway, glad to see it's been sorted. I'd say PHP is best.

Jxhn
31-01-2009, 02:40 PM
Possible via Javascript:

var ip = '<!--#echo var="REMOTE_ADDR"-->';
either use document.write or use a popup to display it ;).

That's a server side include that for some reason has been combined with javascript. You could just do:

Your IP is: <!--#echo var="REMOTE_ADDR"-->

Both examples require certain configurations to work, otherwise every XSS vulnerability would be alot more serious.

Meti
28-02-2009, 08:09 PM
I tried "<!--#echo var="REMOTE_ADDR" -->"

It does not work..

Blackcomb
01-03-2009, 06:50 AM
Fighting over single and double quotes...

Calgon
01-03-2009, 09:37 AM
I tried "<!--#echo var="REMOTE_ADDR" -->"

It does not work..

Page has to be *.shtml

Meti
01-03-2009, 10:59 AM
Oh Kk. Thank you :)

+rep

Calgon
16-05-2009, 09:13 AM
fnx i lyk 2

Meti
18-05-2009, 01:17 PM
No need to bump the thread?
Can a MOD close thread please :P

Jam-ez
18-05-2009, 01:19 PM
No need to bump the thread?
Can a MOD close thread please :P

No need to close on such a small forum area, but the reason he's banned is because he posted that with a load of.. pictures. I'm suprised his post wasn't removed.

AlexBrooks
19-05-2009, 02:05 PM
If you just want to use HTML, you can use a iFrame which loads a page on another server, such as whatsmyip.org position the iFrame loading page to only load the section which displays the IP address.

Meti
22-05-2009, 10:49 AM
That's a good idea AlexBrooks. Thanks :) +rep

Want to hide these adverts? Register an account for free!