Lab 7
.pdf
keyboard_arrow_up
School
Indiana University, Purdue University, Indianapolis *
*We aren’t endorsed by this school
Course
210
Subject
Computer Science
Date
Feb 20, 2024
Type
Pages
6
Uploaded by HighnessYakMaster1036
I210 Information Infrastructure I ©Louie Zhu 1 Lab 7: Use functions and file inclusion in the PHP Online Bookstore In this lab, you will modify the PHP Online Bookstore application you created in a previous lab. There are two major tasks: 1), create library files for header and footer to modularize the Web site; 2), create the “
Guessing the number
”
game using functions and conditional statements. Preview the complete application at https://i210.sitehost.iu.edu/
. The following is a screen shot of the site’s homepage. The page consists of three sections: the header, the main body, and the footer. To make the site look consist, the header and footer appear on every page on the site. Only the main body contains page-specific content. Getting ready 1.
Download the Lab07.zip
file from Canvas and extract it into the htdocs/I210
folder on your computer. The extraction should create a folder named Lab07
with six PHP files and two subfolders in it. 2.
Start PhpStorm and run the Lab07/index.php
file in the I210
project. Click the List Books
link from the navigation bar and then the Beginning Cake PHP and
PHP Bible links to display the details pages.
Part 1: Modularizing your code To better reuse and manage code, code for the navigation bar and banner needs to be stored in a library file named header.php
; code that creates the horizontal line and copyright information at the bottom of the pages needs to be stored in another library file named footer
.
php
. Store the two files in the includes
folder. Main body: content is page specific content footer header
I210 Information Infrastructure I ©Louie Zhu 2 Create the header.php and footer.php files 1.
Create two PHP files (not PHP Web pages) inside the existing includes
folder and name them header
.
php
and footer
.
php
. Delete all code in the two files. Modify the index.php file 2.
Open index.php
file in PhpStorm. Add your name and today’s date in the head section. Move all lines of code above the HTML comments that read “page specific code starts” into the header
.
php
file. Move all lines of code below the HTML comments that read “page specific code ends” to the footer
.
php
file. 3.
At the top of the index.php
page, add a new PHP code block. Inside the code block, two things need to be done: a.
Create a PHP variable named title
and initialize the variable with the page title “PHP Online Bookstore Home”.
b.
Use the PHP command require
to include code from the header
.
php
file. Note that the header
.
php
is stored in the includes
folder. 4.
At the bottom of the
index.php
page, add a new PHP code block. Inside the code block, use the PHP command require
to include code from the footer
.
php
file. Note that the footer
.
php
file is stored in the includes
folder. Modify the header.php file 5.
Switch to header
.
php
in PhpStorm. 6.
Modify the HTML title
tag so the page’s title is
the output of echoing the PHP variable named title
. 7.
In the navigation bar, add a hyperlink that links to the game.php
file. Modify other PHP Web pages 8.
For all other PHP Web pages, you need to delete the code that is already in header and footer, and then use the instructions in Steps 3 & 4 to require the header.php
and footer.php
files. Please use following titles for those Web pages: a.
beginningcakephp.php Beginning Cake PHP b.
phpbible.php PHP Bible, 2
nd
Edition c.
books.php Books in Our Store d.
game.php Guessing the Number Game
I210 Information Infrastructure I ©Louie Zhu 3 Part 2: Creating the Guessing the Number game The game starts with generating a random number between 1 and 20 (Note: to make the game more challenging, you can use a wider range). The random number only needs to be generated once, when the game just starts, and is available throughout the whole game session by posting it back to the page using a hidden form filed. The player plays the game by typing a number into the textbox and then pressing the Guess
button. The application then compares the player’s guessed number with the random. The message “Y
our guess ‘
guess’
was too high.” or “Your guess
‘
guess’
was too low.” displays if the guessed number is larger than or smaller than the random. If the player’s guess is correct, the messa
ge displays “
Congratulations! You guessed the hidden number!!!
”.
9.
Open game.php
file in PhpStorm. Review the current code. You will notice a form containing a text box, a button, and a hidden field. Please note these important things about the form and form elements: a.
The form uses the “post” method to post data.
b.
The form posts data back to the page that contains the form (the page itself). c.
The text box named guess
is a number field and accepts player
’s guess.
It is a required filed. d.
The hidden field random
stores the system-generated random number. Defining the function that compares two integers 10.
Inside the PHP code block at the top of the script file, define a function. The function should compare the two parameters and return a number (-1, 0, or 1) that indicates whether the first parameter is smaller than, larger than, or the same as the second parameter. Define the function using following settings:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Create a simple program for a quiz
Software Requirements:
Latest version of NetBeans IDE
Java Development Kit (JDK) 8
Procedure:
Create a folder named LastName_FirstName (ex. Dahan yoon) in your local
Create a new project named LabExer5B. Set the project location to your own
The program shall:
contain an array of 10 multiple choice questions with three (3) choices each and
require the user to choose among A, B, or C;
Note: Cases are ignored. Lowercase letters are acceptable (a, b, c).
Create a try-catch structure to handle three (3) exceptions. These are when the user inputs the following:
an invalid letter (not A, B, or C)
a number or any special character
blank (no answer)
Prompt the user that he can answer again if any of the three (3) exceptions is
Display the score.
arrow_forward
Case study:
You are required to develop an application to keep track of meeting minutes. Every time a formal meeting takes
place, corresponding meeting minutes should be generated. Each meeting has a list of participants, which the
system receives from the caller of the meeting. The caller also assigns the role of meeting secretary to one of the
participants. The contents of the minutes are usually text, however, images and audio clips can also be attached to
the minutes. The number of attachments is not limited. For each meeting, minutes can only be created by the
assigned meeting secretary (for that meeting), who is also responsible for uploading the attachments. Minutes can
be created incrementally. Once the secretary is satisfied with his/her draft, the minutes can be broadcast to the
participants, who can then make comments on the minutes. Participants can make comments on the minutes as a
whole. These are global comments. They can also select particular sections of the minutes…
arrow_forward
Case study:
You are required to develop an application to keep track of meeting minutes. Every time a
meeting takes place, the corresponding meeting minutes should be generated. Each meeting has a
list of participants, which the system receives from the person calling the meeting. The caller
also acts as the meeting secretary and creates the meeting minutes. The contents of the minutes
are usually text, however, some minutes can also be audio or video content. The contents can be
added incrementally. Once the secretary/caller is satisfied with his/her work, they can choose to
broadcast the minutes to the participants, who can then make comments on the minutes.
The system is going to be web-based. Whenever a user logs in, he/she should see a list of
upcoming meetings, completed meetings. The user should also see different lists for meetings
he/she has called. All user options should be accessible via menus. Participants can make
comments on meeting minutes by clicking on the link of a…
arrow_forward
The above screen is used to browse the products table it uses the ProductDAO.java file, it calls the getProductByCriteria() function which should accept a parameter, this parameter should be the criteria that would be built from the two combo boxes and the text box, and queries the products table.The getProductByCriteria() function should return a list of Product objects that matches the criteria specified.
Modify the function so that it accepts a string paramater consisting of the fields from the combo boxes and a price number from the text box separated by commas and use this string to modify the query in the function to return the desired result set.
public List<Product> getProductByCriteria() //MAKE MODIFICATIONS TO THIS FUNCTION SO IT CAN TAKE PARAMETER(S)
{
if (openConnection())
{
try{
List<Product> items = new ArrayList <> ();
Product temp = null;
String…
arrow_forward
Computer Science
Javascript
populateSelectMenu function
The function populateSelectMenu should exist.
The function populateSelectMenu should return undefined if it does not receive users data.
The function populateSelectMenu selects and returns the select menu.
The function populateSelectMenu receives the option elements from createSelectOptions and appends them to the select element.
arrow_forward
Computer Science
The goal of this assignment is to create an app that can capture, tag, save, and retrieve photos on your smartphone.Capture: When clicked, it takes a picture and shows a thumbnail image. Tag: A user can type multiple tags (separated by a “;”). Save: When clicked, it saves the photo in a database along with the tags. Load: A user can specify one or more tags. Your app will find and show the first photo that had any of those tags. When there are multiple photos matching the criteria, the App should have an UI element to show them one by one, e.g., when the user slides a slider.
arrow_forward
Write a Java GUI application that will keep track of student results at a local college and save the process result into a database. The application must contain the result that a student has obtain for a test, assignment and exam.
Question 1
On the form create a list box that will allow the user to select the student ID populate populate from the text file. Also create a search button when clicked will display the average , highest and lowest result according to the student number and a Save button to save the result to an online data base. Student number should be used as a primary key for your database.
Question 2
Create a sequential file (student.txt) that contains data for the following fields
The student ID number
The student test result
The student assignment result
The student exam result
Question 3
Load the data from the student.txt file and populate the list box with the student numbers
Question 4
Calculate the average result obtained by the student.
Question 5…
arrow_forward
Write a Java GUI application that will keep track of student results at a local college and save the process result into a database. The application must contain the result that a student has obtain for a test, assignment and exam.
Question 1
On the form create a list box that will allow the user to select the student ID populate populate from the text file. Also create a search button when clicked will display the average , highest and lowest result according to the student number and a Save button to save the result to an online data base. Student number should be used as a primary key for your database.
Question 2
Create a sequential file (student.txt) that contains data for the following fields
The student ID number
The student test result
The student assignment result
The student exam result
Question 3
Load the data from the student.txt file and populate the list box with the student numbers
Question 4
Calculate the average result obtained by the student.
Question 5…
arrow_forward
Create an application which is going to find out your maximum grade out of your Midterm grades.
Your program should do the following activities:
●
Create a list consist of your midterm grades.
• Create a variable which keeps your school ID.
●
Create a variable which keeps your name.
.
Create a variable which keeps your date of birth.
Create a variable which calculates the average of the list.
●
.
The maximum grade of the list will be displayed in such a format:
.
You are going to use max() function in order to find the maximum grade.
·
You are going to find average of the list.
The following output will be on the screen:
My name is
and my maximum midterm grade is
The average of my midterm grades are_________.
Do not forget to use comment tag in order to explain each line.
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Related Questions
- Create a simple program for a quiz Software Requirements: Latest version of NetBeans IDE Java Development Kit (JDK) 8 Procedure: Create a folder named LastName_FirstName (ex. Dahan yoon) in your local Create a new project named LabExer5B. Set the project location to your own The program shall: contain an array of 10 multiple choice questions with three (3) choices each and require the user to choose among A, B, or C; Note: Cases are ignored. Lowercase letters are acceptable (a, b, c). Create a try-catch structure to handle three (3) exceptions. These are when the user inputs the following: an invalid letter (not A, B, or C) a number or any special character blank (no answer) Prompt the user that he can answer again if any of the three (3) exceptions is Display the score.arrow_forwardCase study: You are required to develop an application to keep track of meeting minutes. Every time a formal meeting takes place, corresponding meeting minutes should be generated. Each meeting has a list of participants, which the system receives from the caller of the meeting. The caller also assigns the role of meeting secretary to one of the participants. The contents of the minutes are usually text, however, images and audio clips can also be attached to the minutes. The number of attachments is not limited. For each meeting, minutes can only be created by the assigned meeting secretary (for that meeting), who is also responsible for uploading the attachments. Minutes can be created incrementally. Once the secretary is satisfied with his/her draft, the minutes can be broadcast to the participants, who can then make comments on the minutes. Participants can make comments on the minutes as a whole. These are global comments. They can also select particular sections of the minutes…arrow_forwardCase study: You are required to develop an application to keep track of meeting minutes. Every time a meeting takes place, the corresponding meeting minutes should be generated. Each meeting has a list of participants, which the system receives from the person calling the meeting. The caller also acts as the meeting secretary and creates the meeting minutes. The contents of the minutes are usually text, however, some minutes can also be audio or video content. The contents can be added incrementally. Once the secretary/caller is satisfied with his/her work, they can choose to broadcast the minutes to the participants, who can then make comments on the minutes. The system is going to be web-based. Whenever a user logs in, he/she should see a list of upcoming meetings, completed meetings. The user should also see different lists for meetings he/she has called. All user options should be accessible via menus. Participants can make comments on meeting minutes by clicking on the link of a…arrow_forward
- The above screen is used to browse the products table it uses the ProductDAO.java file, it calls the getProductByCriteria() function which should accept a parameter, this parameter should be the criteria that would be built from the two combo boxes and the text box, and queries the products table.The getProductByCriteria() function should return a list of Product objects that matches the criteria specified. Modify the function so that it accepts a string paramater consisting of the fields from the combo boxes and a price number from the text box separated by commas and use this string to modify the query in the function to return the desired result set. public List<Product> getProductByCriteria() //MAKE MODIFICATIONS TO THIS FUNCTION SO IT CAN TAKE PARAMETER(S) { if (openConnection()) { try{ List<Product> items = new ArrayList <> (); Product temp = null; String…arrow_forwardComputer Science Javascript populateSelectMenu function The function populateSelectMenu should exist. The function populateSelectMenu should return undefined if it does not receive users data. The function populateSelectMenu selects and returns the select menu. The function populateSelectMenu receives the option elements from createSelectOptions and appends them to the select element.arrow_forwardComputer Science The goal of this assignment is to create an app that can capture, tag, save, and retrieve photos on your smartphone.Capture: When clicked, it takes a picture and shows a thumbnail image. Tag: A user can type multiple tags (separated by a “;”). Save: When clicked, it saves the photo in a database along with the tags. Load: A user can specify one or more tags. Your app will find and show the first photo that had any of those tags. When there are multiple photos matching the criteria, the App should have an UI element to show them one by one, e.g., when the user slides a slider.arrow_forward
- Write a Java GUI application that will keep track of student results at a local college and save the process result into a database. The application must contain the result that a student has obtain for a test, assignment and exam. Question 1 On the form create a list box that will allow the user to select the student ID populate populate from the text file. Also create a search button when clicked will display the average , highest and lowest result according to the student number and a Save button to save the result to an online data base. Student number should be used as a primary key for your database. Question 2 Create a sequential file (student.txt) that contains data for the following fields The student ID number The student test result The student assignment result The student exam result Question 3 Load the data from the student.txt file and populate the list box with the student numbers Question 4 Calculate the average result obtained by the student. Question 5…arrow_forwardWrite a Java GUI application that will keep track of student results at a local college and save the process result into a database. The application must contain the result that a student has obtain for a test, assignment and exam. Question 1 On the form create a list box that will allow the user to select the student ID populate populate from the text file. Also create a search button when clicked will display the average , highest and lowest result according to the student number and a Save button to save the result to an online data base. Student number should be used as a primary key for your database. Question 2 Create a sequential file (student.txt) that contains data for the following fields The student ID number The student test result The student assignment result The student exam result Question 3 Load the data from the student.txt file and populate the list box with the student numbers Question 4 Calculate the average result obtained by the student. Question 5…arrow_forwardCreate an application which is going to find out your maximum grade out of your Midterm grades. Your program should do the following activities: ● Create a list consist of your midterm grades. • Create a variable which keeps your school ID. ● Create a variable which keeps your name. . Create a variable which keeps your date of birth. Create a variable which calculates the average of the list. ● . The maximum grade of the list will be displayed in such a format: . You are going to use max() function in order to find the maximum grade. · You are going to find average of the list. The following output will be on the screen: My name is and my maximum midterm grade is The average of my midterm grades are_________. Do not forget to use comment tag in order to explain each line.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage