Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

As you gain experience with server-side scripting, you discover increasingly sophisticated ways to improve the user experience. In this Application, you explore the techniques of

As you gain experience with server-side scripting, you discover increasingly sophisticated ways to improve the user experience. In this Application, you explore the techniques of file storage and session variables. To prepare for this Application: Saving to a File An online order system is not very useful if it cannot remember the orders it accepts. Operating systems allow programs to read and write files so that they may store information. Websites frequently rely on more sophisticated database management systems, but that is beyond the scope of this course. The fundamental operations you use on a file are: Open: Find or create the file and make it available to the program Read: Get content from the file Write: Add or modify content in a file Close: Disconnect the file from the program In your order processing page, add the code necessary to save to a file the date, name, age, and item for every order. Which use indicator allows the program to add new data to the end of the file? Does each order appear on a separate line in your file? Write the escape code " " (backslash followed immediately by the letter "n") at the end of the file output. This code tells PHP to end the line there. The next record will start on a new line. How can you tell where one value ends and the next value begins in the file? You could try separating the fields with a comma or some other specific character. What problems do you see with this method? How can you address them? Include your completed PHP source code and a screenshot of the file contents. Using Session Variables Websites often rely on client cookies to remember information (called "state") about a user. The Web browser can store cookies for a specific or an indefinite period. Developers also use server-side session keys to retain state for a limited time. You now use session variables to remember a user's name and age. The idea is to save a customer from having to provide the same information several times in a session. Add PHP code to your "catalog" order-processing page to: Call the session_start function. Detect whether or not the name session variable has a value (use the array_key_exists function); if not, use the name and age post values to set the name and age session variables. Use the session variables, not the post variables, in the confirmation message and when writing to the file. The effect of these changes is to remember the user's name and age after the user has a successful submission. Verify that this page still works properly. Next, modify your "catalog" page to: Call the session_start function. Detect whether or not the name session variable has a value; if so, display name and age as text; if not, display the name and age input fields. These changes take advantage of the saved information. Describe the additional changes you would have to make to "forget" a user's name and age. Submit your pages to the W3C validator (http://validator.w3.org/) and correct all errors. (Note: You may ignore an error concerning placement of the script element.) Include screenshots of the results in your submission. Also include the full XHTML or PHP code for each page, and screenshots of the pages as your Web browser displays them. Summarize the steps you followed to create and perfect the Web site. Outline the difficulties you encountered and how you resolved them.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions

Question

What is job enlargement ?

Answered: 1 week ago

Question

what is the most common cause of preterm birth in twin pregnancies?

Answered: 1 week ago

Question

Which diagnostic test is most commonly used to confirm PROM?

Answered: 1 week ago

Question

What is the hallmark clinical feature of a molar pregnancy?

Answered: 1 week ago