Server-side scripting

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 “n” (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 ( 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.

#Serverside #scripting

Share This Post


Order a Similar Paper and get 15% Discount on your First Order

Related Questions