wejofost Posted January 2, 2010 Share Posted January 2, 2010 Very simple problem but got me beat. I am trying to capture and print on the screen the IP address that is looking at my webpage. After a lot of research I believe I have the data but cannot print it in PHP ( in an ASP WRITE RESPONSE type manner) Here is my test page. What am I doing wrong ?! <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <body> <?php $page ='Test page'; $ipaddress = $_SERVER['REMOTE_ADDR']; $date = date ("M dS H:i:s"); $message = "$page _ $ipaddress _ $date\n"; $File = "track.txt"; $Open = fopen($File, "a+"); if ($Open){ fwrite($Open, "$message"); fclose ($Open); } <br> print this is a print on the screen statement; <br> print $message; <br> <br> Some test data to see if it can be displayed. $result = "OK"; $update = "Yes"; $updateid = "90094"; echo "result=".$result."\n"; echo "update=".$update."\n"; echo "updateid=".$updateid."\n"; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/186968-display-values-on-current-screen/ Share on other sites More sharing options...
mikesta707 Posted January 2, 2010 Share Posted January 2, 2010 echo $_SERVER['REMOTE_ADDR']; thats all you really need to do Quote Link to comment https://forums.phpfreaks.com/topic/186968-display-values-on-current-screen/#findComment-987326 Share on other sites More sharing options...
wejofost Posted January 2, 2010 Author Share Posted January 2, 2010 Thank you Mike . I have added your suggested line to my test page. I have 4 similar lines in my test page but echo is displaying the code but not displaying results on the screen?? Please look at test page www.theparrys.co.uk/test.html It is something stupid that I am doing ( or not doing more likely ) Quote Link to comment https://forums.phpfreaks.com/topic/186968-display-values-on-current-screen/#findComment-987363 Share on other sites More sharing options...
trq Posted January 3, 2010 Share Posted January 3, 2010 You need to save the file with the php extension, not html. Quote Link to comment https://forums.phpfreaks.com/topic/186968-display-values-on-current-screen/#findComment-987364 Share on other sites More sharing options...
oni-kun Posted January 3, 2010 Share Posted January 3, 2010 Thank you Mike . I have added your suggested line to my test page. I have 4 similar lines in my test page but echo is displaying the code but not displaying results on the screen?? Please look at test page www.theparrys.co.uk/test.html It is something stupid that I am doing ( or not doing more likely ) You should really read up on the php documentation (look at my sig), And i'm sure there are many tutorials out there that show the differences between ASP and PHP. Like asp, PHP has it's own file extension and opening style tags. (Note PHP >=5.0 is the current version of PHP, 4.0 and register_globals you should stay away from while learning) Quote Link to comment https://forums.phpfreaks.com/topic/186968-display-values-on-current-screen/#findComment-987375 Share on other sites More sharing options...
wejofost Posted January 3, 2010 Author Share Posted January 3, 2010 Thank you all. Oh what a twit!! Quote Link to comment https://forums.phpfreaks.com/topic/186968-display-values-on-current-screen/#findComment-987391 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.