Web and Database Development Environment PHP Example
Please go through the HTML Example before doing this example.
Create a sample php file
- Go to the examples sub-directory of your web development directory and list the contents of the directory that end in .php:
[username@l-lnx101 username]$ cd /webdev/user/username/examples
[username@l-lnx101 examples]$ ls *.php
- There are two scripts which are example of using php to connect to a mysql database and a postgresql database. You can edit/view them with nano by typing nano sample_mysql.php or nano sample_psql.php.
- Using nano, we can create tutorial.php:
[username@l-lnx101 examples]$ nano tutorial.php
- Copy and paste the following code into your nano screen:
print "REMOTE_ADDR is $ip";
print "Lookup of $ip is <strong>$userhost</strong>\n";
- Save the file and go to http://webdev.cs.uiowa.edu/~username/examples/tutorial.php where username is replaced with your divmsid.
- The page when viewed on l-lnx100 in the lab looks like:
REMOTE_ADDR is 22.214.171.124
Lookup of 126.96.36.199 is l-lnx100.divms.uiowa.edu