Write an HTML document to provide a form that collects family names and telephone numbers. The family name should start with a capital letter, followed by at least one lowercase letter, and not include any spaces or any other characters, and the length should not be more than 30 characters. The phone numbers must be in the format (ddd)-ddd-dddd. Write a PHP script that checks the submitted last name and the telephone number to be sure that they conform to the required format and then returns a response indicating whether the format was correct. Use regular expressions to validate the names and phone numbers.
Create a PHP script named a4q2.php, that on the first visit to that page, will ask the user for his/her name in this way:
Then, it will record the user’s name in a session along with the number of visits made, and it will display the following page. After 4 visits, the page should look like this:
In the first case, you should have a form containing an input text field named username and a submit button with text “Send”. The form’s action should be the PHP script itself, and the method should be POST. In other words, the form should post the data to itself.
In the second case, the reset button is not the standard HTML reset button. It should be a submit button with text “Reset”, placed inside a form, with the same action and method as the first form. Besides a button, this second form should contain an input of type hidden, be named reset and have a value equal to yes. This hidden data will be posted to let the script know that we want to reset the session data.
At the top of your PHP file, you should start with a function call to start the session. Then you should check the POST data before doing anything else:
1. If the POST data contains the reset key, and if it is set to yes, then unset the SESSION data and destroy the session.
2. Otherwise, check if the user name key is in the POST data. If yes, then save the user name in the SESSION data, and set the number of visits in the SESSION data to 0.
Then, inside the HTML body, you should determine which of the 2 cases you need to display:
1. If the user name is not set in the SESSION data or if it is empty, then display the “What is your name” form described earlier.
2. Otherwise, if there is a non-empty user name in the SESSION data, then increment the number of visits in the SESSION data, and display the other information, including the user name, the number of visits and the reset form, as described earlier.
NOTES:
1. Use only HTML and PHP for this question (no CSS nor JavaScript).
2. The following HTML elements have been used for text outside the forms: h1, h3 and p.
In this exercise we continue the Hotel Room Reservation 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).
Hotel Room 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)
• Header: It should include the name of your service and a logo/picture. 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.
1) 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 Hotel Rooms information file that will store the information about location, address, number of available rooms, special facilities and price per night. Design your own format and field name for search. For simplicity
assume that you do not need to verify the check-out and check-in dates and all the hotels listed in your file are available for any time interval that the user enters.
2) 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 Hotel Room information file and find the matching hotel. Please notice that you can have none or multiple matchings.
• Login/Create New Account: 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 – Hotel name, area, street address and price per night. If the user does not login, the search results include only the area information without the name and street address, and there should be 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.
Any pictures, graphics, text, code, you “borrow” from other sites, be sure to give credit to.