Lab 4 -- Feb 9

In this lab you will be setting up a very simple web home page and putting some form buttons onto that page.

Set up for a web home page

Everyone (in this class) can set up a homepage on our database server. To do so:
  1. Log into UNIX (any machine will work)
  2. In you home directory create a new directory named public_html This directory must be in your home directory, not in a subdirectory. For instance, for me that would be /home/gtowell/public_html. Be sure that the directory is public readable and executable. (It should be by default.) If it is not, adjust permissions for the directory is readable and executable by the public.
  3. Within the public_html directory create a file test.txt and put something in it (random characters are fine)
  4. Test you work: In a browser, navigate to http://loin.cs.brynmawr.edu/~YOURUNIXLOGIN/test.txt.. For example, for me that would be http://loin.cs.brynmawr.edu/~gtowell/test.txt. If you actually do this for my URL you should see "Hello 383". If you do it for your URL you should see whatever you put into the file test.txt
  5. You are done (with this part). If you cannot get this to work, contact me as it is possible I mis-configured the web server for you.
Having set up your public home directory and tested that it works; now actually create a home page.
  1. In your public_html directory create a file named index.html
  2. Initially put into this file the following contents (whitespace is not significant)
    <!DOCTYPE html>
    <html>
        <body>
            Your Name
        </body>
    </html>
    
  3. Check that this works. In your browser enter the URL http://loin.cs.brynmawr.edu/~YOURUNIXLOGIN You do not need to put "/index.html" at the end. You may, but it is unnecessary since web servers will look for index.html by default is no page is given.
  4. You should see your name in the browser. (When you do not specify a page, the Apache server will, by default, look for a file named index.html and display its contents. Depending on the Apache configuration, if there is no index.html file, the contents of the directory might be shown.

Add forms

Finally add 4, yes 4, forms to your index.html page by simply pasting the following into your page 4 times (between <body> and </body>).

To each form of these forms add at least one element (for instance a text entry box). Each form should have a different type of additional element.
    <form method="post" action="http://165.106.10.133:30008/post-test">
    <input type="submit" value="Submit1">
    </form>
    <form method="get" action="http://165.106.10.133:30008/get-test">
    <input type="submit" value="Submit2">
    </form>
    <form method="post" action="http://165.106.10.133:30008/test">
    <input type="submit" value="Submit3">
    </form>
    <form method="get" action="http://165.106.10.133:30008/test">
    <input type="submit" value="Submit4">
    </form>
When you hit the button, what you will get (mostly) is just echo the content that was submitted with the form back because I created a web server that does exactly this. (We will get to creating such servers soon.). The echo is dependent of the way you set up your form element and what you entered into your forms.

Experiment with your forms add some more elements to them. Notice what changes in the echo as you change the contents of your form. Notice too that the actual URL changes in the second and fourth forms despite the "action" URL in the forms being identical.

That is it, almost.

What to hand in

Send email to gtowell@brynmawr.edu with two pieces of information.
  1. The URL of the page containing your forms
  2. 3 sentences (or so) about the difference between the get and post methods for forms.