#### 您當前位置：首頁 >> CS作業CS作業

###### 日期：2018-12-04 10:21

Concordia University

Computer Science and Software Engineering Department

SOEN 287: Web Programming 1 – Fall 2018

Assignment 4

______________________________________________________________________

Due Date: By 11:55pm, Saturday, December 1, 2018

Type: Individual Assignment

Purpose: The purpose of this assignment is to have you to practice HTML, CSS, JS,

PHP and create a website

CEAB Attributes: This assignment is primarily evaluating your use of Web

programming

Skills (Knowledge base & design)

Exercise 1

The following set of short questions will focus on getting you familiar with how to write

PHP functions as well as how to make use of the pre-existing PHP functions. All your

PHP functions must be declared in the document body section and each functions

name must be as specified below. To demonstrate the functionality of each method, you

must make function calls in the document body. Include a heading (h1 … h6) that

indicates the function is being tested before the function demonstration.

The use of Global Variables is forbidden!

A. Function: findSummation

Parameter(s): A positive integer number (default value is =1)

Given the input positive number (N), find the summation of all positive integer numbers

from 1 to N (1+2+3+….+N) and return this summation. If the input parameter is not a

number, or if it is not a positive number return false.

B. Function: uppercaseFirstandLastSorted

Parameter(s): String

For each word in the input string, capitalize (uppercase) both the first letter and the last

letter, then sort the words alphabetically (assume all the words contains just letters) and

return the modified string.

C. Function: findAverage_and_Median

Parameter: An array of numbers.

Calculate the average and median of the numbers and return both values.

D. Function: find4Digits

Parameter: A string of numbers separated by spaces.

Return the first four-digit number in the string; false if none.

Exercise 2

Create a php page (name it numOfVisits.php) that uses cookies to record and track the

number of times a webpage has been visited. If the visitor is looking at the webpage for

the first time, it should display the following message: Welcome to my webpage! It is

your first time that you are here. If the page has been visited more than once, display:

Hello, this is the ## time that you are visiting my webpage (where ## shows the number

of visits). In this case you should also display a message that shows the day of the

week, date, time and the time zone on your server that the page was visited last time in

the following format (as an example):

Last time you visited my webpage on: Sat November 10 17:16:18 EST 2018

(EST= Eastern Standard Time Zone)

Exercise 3

Write an HTML document to provide a form that collects names and

telephone numbers. The phone numbers must be in the format ddd-ddddddd.

Write a PHP script that checks the submitted telephone number to

be sure that it conforms to the required format and then returns a

response indicating whether the number was correct.

Exercise 4: Project

In this exercise we continue the Cottage Search Problem (from

assignment 3) and will have the goal of building a website. (Note:

since this assignment introduces PHP into the project, it is likely

that some of your web pages will have to have their extensions

changed from .html to .php).

Cottage Search Website

Running Problem – Version 3

This version requires HTML, CSS, JS and PHP.

1) Create a template for your entire site such that you define the header and footer

once and include them in each page of the site. This should be done using PHP.

The following is just as a reminder of what the header and footer should contain.

2)

Clicking on the logo/picture should take you back to the home page. It

should also display the current date and time. The Time should

automatically refresh every second.

Footer: This should appear at the bottom of all your pages. Give it a

distinct background color and include links to a Privacy/Disclaimer

Statement which can either appear in the content area of the site or in an

alert or confirm box. It should display a message promising users that

their information will not be sold or misused, and protects the

website builder from any incorrect information.

3) You will manage 2 text files which will reside on the server.

A login file which will contain username and passwords. This file will be

consulted when a user is logging in. Each field should be separated by

colon (:) and each user info is in one line.

For example if I have a file with 3 accounts, the file will look like so:

user1:pass1

user2:pass2

user3:pass3

An available cottage information file that will store the information about

location, type, amenities, price, pet info. Design your own format and field

name for search.

4) Functionality of your site: Add the following functions to your site:

Search: enter some search criteria and submit the query to a server site PHP

program. This PHP program can search in the available Cottage information

file and find the matching cottages. Please notice that you can have none or

multiple matchings.

o Add a login button at the top-right corner of the search page.

o When a user clicks on this button, a login page loads into the content

area with text fields for a username and one for a password as well as

a login button. Below the login button, you can show a description of

the allowed formats for usernames and passwords. A username can

contain letters (both upper and lower case) and digits only. A password

must be at least 6 characters long (characters are to be letters and

digits only), have at least one letter and at least one digit. Before

sending this information to the server make sure that the entered

username and password satisfy the format criteria just listed.

o A user can input a username and a password on the login page. If the

username and the password is a match verified by a PHP program

against the log in file, redirect the user to the search page with

“welcome, username” at the top-right corner (besides the login button).

If the username exists and the password is not a match verified by a

PHP program against the log in file, stay on the login page and show

“invalid login” before the login button and allow the user to re-enter

inputs. If the username does not exist, write this new pair to the login

file following the format specified in bullet 3 and return a new page to

confirm that the account was successfully created and display a button

to redirect the user to the search page.

Connect the search page and the account login: if the user has logged in,

show the full search results – types, area, street address and price. If the user

does not login, the search results include only the area information, not the

street address and a button “login to show the address” besides each result

item. User can click the button to login. You do not need to cache the search

results. After the login, the search starts again.

Note:

1) Although it is not a functional requirement, your site should always be well

organized with properly named files and well defined directories.

2) Any pictures, graphics, text, code, you “borrow” from other sites, be sure to give

credit to. Be aware of plagiarism.

Submitting Assignment 4

Please give meaningful names to each html, js and php file to make the feedback

process easier.

Naming convention for zip file: Refer to assignment 3 handout.

For submission instructions please refer to the course web page.

Assignments not submitted to the correct location or not in the requested format

will not be graded.

Evaluation Criteria for Assignment 4 (20 points)

Exercise 1 – 4 pts.

a) findSummation()

b) uppercaseFirstandLastSorted

c) findAverage_and_Median

d) find4Digits

1

1

1

1

pt

pt

pt

pt

Exercise 2 - 4 pts.

b) Storing the visits count using cookies

c) Showing the visits count and date & time

1

2

1

pts

pts

pts

Exercise 3 - 2 pts

a) Creating a form

b) Data validation on the form

1

1

pt

pt

Exercise 4 - 10 pts.

a) Header and footer

b) Search php

3

3

4

pts

pts

pts

TOTAL 20 pts