Please go through the HTML Example before doing this example.

Create a sample php file

  1. Using nano, we can create tutorial.php:

    [username@l-lnx101 username]$ nano tutorial.php

  2. Copy and paste the following code into your nano screen:

    <?php
    $ip=$_SERVER["REMOTE_ADDR"];
    print "REMOTE_ADDR is $ip";
    $userhost= gethostbyaddr($_SERVER["REMOTE_ADDR"]);
    print "<br>\n";
    print "Lookup of $ip is <strong>$userhost</strong>\n";
    ?>

  3. Save the file and go to http://webdev.cs.uiowa.edu/webdev/COURSEID/USERNAME/tutorial.php where COURSEID and USERNAME are replaced with your course number and hawkid.
  4. The page when viewed on l-lnx100 in the lab looks like:

    REMOTE_ADDR is 128.255.44.124
    Lookup of 128.255.44.124 is l-lnx100.divms.uiowa.edu