This site applies only to CMPT 165 (Distance Ed) in Summer 2016. See the CMPT 165 sections page for other sections.

This lab is intended to get you started working with form input.

  1. Create an XHTML page with a form that asks the user for a password. You can use a text input for the password, or try type="password" for the <input> tag. (It works the same as a text field as far as your program is concerned.)

    The response when the form is submitted should depend on whether or not the password is correct. If the password entered is “cmpt165”, you should respond with a secret message (of your choosing).

    If the user enters anything else for the password, they should be given an error message:

    <p>Sorry, the password is incorrect.</p>
  2. For this part of the lab, you will create a mini-web-application that tells the user the weekday of a particular date. Start with this form that asks for a date.

    Create a Python program weekday.py that read the input from the form. To determine the day of the week, you can use a function from the calendar module. The weekday function can be called like this:

    weekday = calendar.weekday(y, m, d)

    … assuming you have the year, month, and day in variables y, m, and d. This will put an integer 0–6 in the variable weekday, where 0 is Monday, 1 is Tuesday, and so on.

    Use a series of if statements to produce output like this on the generated page (with the appropriate weekday, of course—this is what you'd produce if the weekday was 0):

    <p>That's a Monday.</p>

When you're done, upload the files from this lab to the course web server. Submit the URLs of the form pages you created to CourSys.