Use the PHP one because some people have javascript disabled.
Printable View
Use the PHP one because some people have javascript disabled.
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):
That would appear something like this:PHP Code:<?php
$ip = $_SERVER['REMOTE_ADDR'];
echo "<i>Your IP address has been logged: " . $ip . ".</i>";
?>
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):
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.PHP Code:$ip = $_SERVER['REMOTE_ADDR'];
Hope I've helped.
why not just
instead of adding all your wacky YOUR IP IS" . $IP OH GOD SET A VARIABLE FOR SOMETHING THAT NEVER CHANGESPHP Code:<?php echo $_SERVER[ 'REMOTE_ADDR' ]; ?>
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.
That's a server side include that for some reason has been combined with javascript. You could just do:
Both examples require certain configurations to work, otherwise every XSS vulnerability would be alot more serious.HTML Code:Your IP is: <!--#echo var="REMOTE_ADDR"-->
I tried "<!--#echo var="REMOTE_ADDR" -->"
It does not work..
Fighting over single and double quotes...