Creating a web Chat Application we will need to do a few things:
There is a concept in web development which I subscribe to called design first development. This is a dangerous thing to do if you don't know much about application development. It sometimes gets similar criticism that Bruce Lee's martial art does. In design first you make your html document and then change it to be an application.
I went ahead and made a base chat html document view_messages.html|
http://danm.ucsc.edu/~lyle/classes/php/chat/view_messages.html].
A few things to note about our html document (do a view source of that document):
Looks like: <div id="chat_log">.......</div>
And inside that chat_log I have a bunch of messages each inside a div. And each message has a person's name.
The form has two inputs:
message - the message they want to send to the chatcreated_by - the person's namemessage field, ready for input.
MySQL is an open source database that is very common with web development. A bit about what a database is.
To manage MySQL you will usually use
phpMyAdmin which is a php web application that allows you to manage a MySQL server.
We need a table to hold our chat messages. We will call the table "messages" and the table will have these fields:
id, this will be unique for every entry and it will auto increment for us.created_at, this will be a time stamp and we will have the database auto assign a now() value.created_by, for our example this will be the user's name.message, this will be the actual content of the messageYou need to figure out how this application will work from a logic perspective. We are going to have two basic work-flows that will interact with each-other.
The view_messages workflow is fairly straight forward and doesn't need a large diagram. It is fairly linear.
Render the HTML
Include the chat messages, notifications to the user, and insert their name/created_by if you know it.
The add_messages workflow has some more complications. Here is a work flow diagram: