(Solved) : Gain Experience Server Side Scripting Discover Increasingly Sophisticated Ways Improve Use Q27939314 . . .
As you gain experience with server-side scripting, you discoverincreasingly sophisticated ways to improve the user experience. Inthis Application, you explore the techniques of file storage andsession variables. To prepare for this Application: Saving to aFile An online order system is not very useful if it cannotremember the orders it accepts. Operating systems allow programs toread and write files so that they may store information. Websitesfrequently rely on more sophisticated database management systems,but that is beyond the scope of this course. The fundamentaloperations you use on a file are: •Open: Find or create the fileand make it available to the program •Read: Get content from thefile •Write: Add or modify content in a file •Close: Disconnect thefile from the program In your order processing page, add the codenecessary to save to a file the date, name, age, and item for everyorder. Which use indicator allows the program to add new data tothe end of the file? Does each order appear on a separate line inyour file? Write the escape code “n” (backslash followedimmediately by the letter “n”) at the end of the file output. Thiscode tells PHP to end the line there. The next record will start ona new line. How can you tell where one value ends and the nextvalue begins in the file? You could try separating the fields witha comma or some other specific character. What problems do you seewith this method? How can you address them? Include your completedPHP source code and a screenshot of the file contents. UsingSession Variables Websites often rely on client cookies to rememberinformation (called “state”) about a user. The Web browser canstore cookies for a specific or an indefinite period. Developersalso use server-side session keys to retain state for a limitedtime. You now use session variables to remember a user’s name andage. The idea is to save a customer from having to provide the sameinformation several times in a session. Add PHP code to your”catalog” order-processing page to: •Call the session_startfunction. •Detect whether or not the name session variable has avalue (use the array_key_exists function); if not, use the name andage post values to set the name and age session variables. •Use thesession variables, not the post variables, in the confirmationmessage and when writing to the file. The effect of these changesis to remember the user’s name and age after the user has asuccessful submission. Verify that this page still works properly.Next, modify your “catalog” page to: •Call the session_startfunction. •Detect whether or not the name session variable has avalue; if so, display name and age as text; if not, display thename and age input fields. These changes take advantage of thesaved information. Describe the additional changes you would haveto make to “forget” a user’s name and age. Submit your pages to theW3C validator (http://validator.w3.org/) and correct all errors.(Note: You may ignore an error concerning placement of the scriptelement.) Include screenshots of the results in your submission.Also include the full XHTML or PHP code for each page, andscreenshots of the pages as your Web browser displays them.Summarize the steps you followed to create and perfect the Website. Outline the difficulties you encountered and how you resolvedthem.
Expert Answer
Answer to Gain Experience Server Side Scripting Discover Increasingly Sophisticated Ways Improve Use Q27939314 . . .
OR