Click here to Skip to main content
15,887,453 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HTML
<HTML>
<HEAD>
<TITLE>Your Title Here</TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF">
<CENTER> Hello </CENTER>

<form>
  <label for="IP">IP</label>
</form>

<?php
$ip = $_SERVER['REMOTE_ADDR'];
echo $ip;

?>

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

</BODY>
</HTML>
Posted
Updated 14-Nov-11 14:05pm
v3
Comments
Member 7965084 14-Nov-11 19:37pm    
the website should show my ip but all php codes are not working
and i upload it in zymic free host
Sergey Alexandrovich Kryukov 14-Nov-11 20:06pm    
Click "Improve question" to see my corrections to format the code properly. You should do it yourself. Also, move your comment above to the body of the question.
--SA

1 solution

I tested it — it does work as expected, only two values showing IP address is written together, just remove one of the two equivalent PHP parts and/or add HTML markup:

PHP
<?php echo "<p>" . $_SERVER["REMOTE_ADDR"] . "</p>"; ?>


If shows the IP address of the user not the server. To show the server IP use $_SERVER["REMOTE_ADDR"] (which is considered unsafe).

Now, the question is: why don't you see it? Check up:

  • Are you sure you deployed this file to the site with HTTP server where PHP module is enabled?
  • Are you sure the file name is "*.PHP"?
  • Are you sure the service settings are tuned to process the files "*.PHP" through PHP?


I hope you understand PHP is the language which should be supported in server side? If you just open this file with some Web browser, PHP part won't be processed… :-)

—SA
 
Share this answer
 
v2
Comments
Member 7965084 15-Nov-11 1:38am    
thank u very mach
Member 7965084 15-Nov-11 1:40am    
my mistake was the name *.html and when i change to php it worked

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900