This course will cover Web site programming. For the first part of the course, you will be using PHP to write active web pages. The first step will be to use PHP to process the data from simple forms, like the one below. This form sends its data to a PHP page. In this case, the PHP page just shows some of the data that is made available by the Web server in the form of preset values for certain PHP variables. Try filling in the form and clicking the submit button. You'll see the data from the form listed as the values of two variables named "$name" and "$email". (All variable names in PHP begin with $.) You'll also see a bunch of "CGI" variables such as $REMOTE_ADDR, which gives the IP number of the machine from which you are connecting.
The variables $name and $email are listed as "POST" variables because POST is the method used by the Web browser in this case to send data to the Web server. An alternative method is GET. With the GET method, the data for PHP variables is provided as part of the URL. For example, try visiting the following URL:
You should see "$foo" and "$time" listed as "GET" variables. In addition, if you have not turned off "cookies" in your browser, you will see another variable "$cookievisits". This variable represents a "cookie" that is set by the PHP page. Each time you visit the env.php page, the value of $cookievisits will be increased by one. (A "cookie" is bit of information that is sent by a Web server that you visit to be stored on your machine. When you access that Web server again, it gets a copy of the cookies that it has stored on your computer. In this case, the cookie is set to be deleted when you quit from the Web browser program.)
All this is just to show you something about how PHP interacts with a Web server and a Web browser. You'll start working in PHP yourself next week. If you would like to see the source code for the PHP page env.php, click here. However, the main point of this introductory lab is to get you started with your Web site for the course.
Connect to your Linux account using X-Win32. Your web site for this course will be stored in a directory named public_html. I have used a little Linux trickery to set up this directory so that its contents are accessible by you (of course) and by the Web server (so it can serve up your pages), but not by other students (so they can't see the source PHP files that you write).
Your site will be visible on any of the cslab machines, but not on math.hws.edu. If your username is jsmith, then you will be able to access your site using any of the URLs: http://cslab0.hws.edu/~jsmith/, http://cslab1.hws.edu/~jsmith/, ..., http://cslab9.hws.edu/~jsmith/. The site will only be accessible from on-campus. Later, if you like what you've done, you can move it into your www directory, where it will be visible globally on the Web at a URL such as http://math.hws.edu/user/jsmith/. However, since math.hws.edu is a production server, I prefer that while the course is in progress, you use the cslab machines for development.
There are two Linux configuration issues that you have to check before working on your site. First, your home directory must have the proper access permission. There are two ways to set this:
The second item should only apply to a few people. In a command line window, give the command umask. If the output is not 022, you have to fix this. The incorrect setting, probably 066, can be found in your .bashrc file. Edit this file. (Note that the file name begins with a period.) You should find a line at the end that says "umask 066". Remove this line and save the file. The next time you log in, or even if you just open a new command-line window, the umask setting should be 022. (The 066 setting prevents other people from seeing the files that you create. This might be a good thing, but it also prevents the Web server from seeing them, so your Web site would not be accessible.)
You should spend some time, either during lab or later, looking through the brief Linux documentation that I have posted at http://math.hws.edu/eck/about_linux/.
You can try out bluefish on the main page of your Web site. Start up the bluefish program. (For example, choose "Run Command" from the K menu, then enter "bluefish" in the window that pops up.) You can get the basic outline of a Web page with the "Dialogs > General > Quickstart" command. (The shortcut for this command is ALT-Q, but note that under X-Win32 you might have to use the right ALT key, since the left ALT key is used for Windows.) Just fill in a title for your page in the dialog box that pops up when you give this command. Now, you just have to fill in the body of the page!
You might want to try the "weblint" command in the "External" window. This runs an HTML syntax checker and shows the result in a window. An empty window means no HTML syntax errors were found. Try making some error, to see that weblint finds it.
Save your page in your public_html directory with the name index.html. The index.html file is the main page of your web site.
If you want to be able to start netscape from within bluefish to preview your work, you have to make a change in the bluefish configuration so that it will know where to find netscape. (However, I really recommend running netscape separately and accessing your pages through the Web. You will have to do this to view PHP files, in any case.) Select the "Preferences" command from the "Options" menu. Click the "External" tab. In the top box, change "/usr/local/netscape/netscape" to "/opt/netscape/netscape". Click the "Save&Close" button. Note that you still have to save a file, so that it has a name, before you can view it with netscape.
If you want to make it easier to start up bluefish, you can add an icon to your desktop. Right-click on the desktop. In the pop-up menu, under "Create New", select "Link to Application". In the dialog box, enter "bluefish" in the box on the first screen. This will be the name of the icon. (The icon will appear as the generic "gear" icon that you see next to this box. If you want to select a better icon, click the gear icon.) Now, click the "Execute" tab and enter "bluefish" as the Command. Click OK. The icon should appear on the desktop. You can start bluefish by clicking this icon. You can open a file with bluefish by dragging the file's icon onto the bluefish icon. Note that you can also open a file with bluefish by right-clicking the file in a directory window, selecting "Open with" from the pop-up menu, and entering bluefish as the name of the program to use.
As your first assignment, you should create a main page for your web site for this course and make sure that is accessible from the Web servers on the cslab computers. (If you need a very quick refresher on the basics of HTML see Section 6.2 of my Java textbook at http://math.hws.edu/javanotes/c6/s2.html.) I will check your Web page before class next Wednesday. You should spend the rest of the class either working on this page or exploring your Linux account or exploring bluefish.