Due: 17 Feb 2012, 11:59pm
AbstractIn this assignment, you will be augmenting the "forever alone" chat (Assignment 6) to save chat history, among other functionality. If you were not able to finish the prior assignment or would prefer to not use your solution, you may use the Instructor Solution for Assignment 6 as a code base.
AssignmentStarting from the original forever alone chat, create an additional PHP file called alonesave.php that will process POST data sent to it by your chat form. You should rename the alone.html file to alone.php.
The sequence of events when a user views your site is as follows:
Your main file must be named alone.php, whereas your processing file must be named alonesave.php. Your JavaScript file must be named alone.js, and your CSS file must be named alone.css. Additionally, for this assignment, you are required to have a file called alonehistory.txt which will contain all of the chat messages sent to the chat.
NotesThe timestamp that you prepend to a message should be in the form: (MM/DD/YYYY @ 24hr-time), e.g. (11/16/1974 @ 1300), (10/13/1961 @ 0900), (02/23/1964 @ 2010). Information for using PHP's date function is located at http://php.net/manual/en/function.date.php. Date string "m/d/Y @ Hi" should help.
Do not use any HTML or JavaScript redirects. All redirects are to be handled by PHP. This can be accomplished with header("Location: alone.php"); . This function allows you to add a raw HTTP header that gets sent back to the client.
Scrolling to the bottom of the chat window is accomplished using the 'scrollTop' and 'scrollHeight' DOM attributes. Both divs and textareas have these attributes and, by setting the element's scrollTop to its scrollHeight will automatically scroll the element as far down as possible (e.g. aDivInYourCode.scrollTop = aDivInYourCode.scrollHeight;). Hint: you may consider utilizing the window.onload event handler in your JavaScript code.
As usual, your HTML output is still required to be valid HTML5. Validation will be done through http://validator.w3.org.
HintsFor file reading and writing in PHP, we recommend the functions file_put_contents and file_get_contents.
Homework SubmissionAs detailed on the homework submission page, this homework must be on the class web server in a folder titled homework8 for it to be graded.