Skip to content

Instantly share code, notes, and snippets.

@AJNOURI
Last active June 26, 2016 02:43
Show Gist options
  • Save AJNOURI/afa8475340a2bc8a0e44 to your computer and use it in GitHub Desktop.
Save AJNOURI/afa8475340a2bc8a0e44 to your computer and use it in GitHub Desktop.
php inside html to detect ip address
<?php
header('Content-Type: text/plain');
echo "Server IP: ".$_SERVER['SERVER_ADDR'];
echo "\nClient IP: ".$_SERVER['REMOTE_ADDR'];
echo "\nX-Forwarded-for: ".$_SERVER['HTTP_X_FORWARDED_FOR'];
?>
<div class="content_section floating_element">
<div class="section_header section_header_red">
<div id="about"></div>
It works!
<p>
<?php
echo "Local server IP = ".$_SERVER['SERVER_ADDR'];
?>
</p>
<p>
<?php
echo "IP used by client = ".$_SERVER['HTTP_HOST'];
?>
</p>
<p>
<?php
echo "DNS name used by client = ".$_SERVER['SERVER_NAME'];
?>
</p>
<?php
header('Content-Type: text/plain');
echo "Server IP: ".$_SERVER['SERVER_ADDR'];
echo "\nClient IP: ".$_SERVER['REMOTE_ADDR'];
echo "\nIP used by client = ".$_SERVER['HTTP_HOST'];
echo "\nX-Forwarded-for: ".$_SERVER['HTTP_X_FORWARDED_FOR'];
echo "\nDNS name used by client = ".$_SERVER['SERVER_NAME'];
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment