Sourceofarticles.com Menu
Newest Articles
Most Viewed Articles
Sourceofarticles.com RSS
Submit Article
Login
Signup
Search the articles

Articles Main Categories
Advice
Animals
Automobiles
Business
Career
Communications
Computer Programming
Computers
Entertainment
Environment
Family
Fashion
Finance
Food
Health & Medical
Home & Garden
Humor
Internet Business
Internet Marketing
Legal
Leisure & Recreation
Marketing
Other
Politics
Reference & Education
Religion
Self Improvement
Sports
Technology & Science
Travel
Writing
Subscribe
Receive alert message from us when new articles submitted to our site for free.

Enter your name

Enter your email

Syndicate

















Related Products
NIKE Dri-Fit Running Cycling Baseball Hat Cap Unisex
US $12.99 (0 Bid)
End Date: Friday Nov-21-2008 15:06:47 PST
Buy It Now for only: US $14.99
Bid now | Buy it now | Add to watch list

New LOUIS GARNEAU Downhill Cycling Jersey Long Sleeve S
US $19.99 (0 Bid)
End Date: Friday Nov-21-2008 15:08:42 PST
Buy It Now for only: US $22.99
Bid now | Buy it now | Add to watch list

New Team Highroad Columbia Road Cycling Hat Cap Apparel
US $9.99 (1 Bid)
End Date: Friday Nov-21-2008 15:08:55 PST
Bid now | Add to watch list

New Team Highroad Columbia Road Cycling Hat Cap L-XL
US $9.99 (0 Bid)
End Date: Friday Nov-21-2008 15:17:43 PST
Bid now | Add to watch list

Verge cycling vest 2XL used
US $14.99 (1 Bid)
End Date: Friday Nov-21-2008 15:18:41 PST
Bid now | Add to watch list

SHIMANO SH-M032 CYCLING SHOES 42
US $9.99 (0 Bid)
End Date: Friday Nov-21-2008 15:21:21 PST
Bid now | Add to watch list

Tour de France VAL D'ISERE 2007 Cycling Poster Print
US $29.94 (0 Bid)
End Date: Friday Nov-21-2008 15:27:21 PST
Buy It Now for only: US $29.99
Bid now | Buy it now | Add to watch list

Ladies Bicycle Cycling & Running Shirt Exercise Jersey
US $42.00 (0 Bid)
End Date: Friday Nov-21-2008 15:30:00 PST
Bid now | Add to watch list

21 LED Bike Bicycle Front Lamp+Cycling 5 LED Rear Light
US $8.89
End Date: Friday Nov-21-2008 15:30:43 PST
Buy It Now for only: US $8.89
Buy it now | Add to watch list

Running, Cycling, Workout, Weight Training Log Software
US $19.99 (0 Bid)
End Date: Friday Nov-21-2008 15:33:00 PST
Buy It Now for only: US $24.99
Bid now | Buy it now | Add to watch list

MENS FRANCE CYCLING SKINSUIT
US $9.99 (0 Bid)
End Date: Friday Nov-21-2008 15:36:26 PST
Buy It Now for only: US $25.00
Bid now | Buy it now | Add to watch list

Home::CGI

Design an Online Chat Room with PHP and MySQL

Author : Rory Canyon

In this article, you will learn how to design and develop a
simple online chat room with PHP and MySQL. This tutorial
explains every steps of the development, including both database
design and PHP programming. Basic computer skills and knowledge
of HTML and PHP are required. Ok, let's begin now.

Step 1: Design Database Table. Create table "chat" in MySQL
database to store basic chat information: chtime (chat time),
nick (user nickname) and words (chat message, less than 150
characters)

mysql> CREATE TABLE chat

-> chtime DATATIME,

-> nick CHAR (10) NOT NULL,

-> words CHAR (150);

Step 2: Design Structure. This simple online chat room includes
the following four sections: user login, message display,
message input and a main frame integrating the display and input
sections. Thus, it needs the following four files to work:
login.php, main.php, display.php and speak.php.



Step 3: Write the code

1. login.php (just a HTML form)





User Login





Please input your nickname and enter















2. main.php


setcookie("nick",$nick) //use cookie to store user nickname

?>



My Chat Room











3. display.php

This file is used to get message records from database and
display the results. To keep the size of database, old messages
are deleted and only the newest 15 messages are displayed.





Display Messages








//connect to mysql server, server name: main, database username:
root

$link_ID=mysql_connect("main","root");

mysql_select_db("abc"); //abc is the database name

$str="select * from chat ORDER BY chtime;" ;

$result=mysql_query($str, $link_ID);

$rows=mysql_num_rows($result);

//get the latest 15 messages

@mysql_data_seek($resut,$rows-15);

//if the number of messages<15, get all of the messages

if ($rows<15) $l=$rows; else $l=15; for ($i=1;$i<=$l; $i++) {

list($chtime, $nick, $words)=mysql_fetch_row($result);

echo $chtime; echo " "; echo $nick; echo":" ; echo $words; echo
"
";

} //delete the old messages(only keep the newest 20 only)

@mysql_data_seek($result,$rows-20);

list($limtime)=mysql_fetch_row($result);

$str="DELETE FROM chat WHERE chtime<'$limtime' ;" ;

$result=mysql_query($str,$link_ID);

mysql_close($link_ID);

?>





4. speak.php





Speak






If ($words)

{ $link_ID=mysql_connect("main","root");

mysql_select_db("abc"); // abc is the database name

$time=date(y).date(m).date(d).date(h).date(i).(date(s); //get
current time

$str="INSERT INTO chat(chtime,nick,words) values
('$time','$nick','$words');" ;

mysql_query($str,$link_ID); //save message record into database

mysql_close($link_ID); )

?>

//the following is the message input form













Now, you have finished the design and coding of a simple online
chat system. Put all the files into your website root and see
how it works, :)

Related articles


  1. 5 CGI Scripts You Must Use to Turn Your Site Into a Powerhouse
  2. Clever Profit Growth Software
  3. Why Aren't You Using CGI
  4. Use CGI to Automate Your Web Site
  5. CGI: What the Heck Is That?
  6. CGI Security Issues
  7. How to Stop Digital Thieves with CGI
  8. Quick Intro to PHP Development
  9. Better Writing: What Works and What Doesn't
  10. Password Protection and File Inclusion With PHP
  11. Autoresponders With PHP
  12. Track your visitors, using PHP
  13. PHP On-The-Fly!
  14. PHP and Cookies; a good mix!
  15. Screen scraping your way into RSS
  16. Mastering Regular Expressions in PHP
  17. ASP, CGI and PHP Scripts and Record-Locking: What Every Webmaster Needs To Know
  18. Open Source Scripts
  19. this is a test
  20. An Extensive Examination of the PHP:DataGrid Component: Part 1
  21. PHP:Form Series, Part 1: Validators & Client-side Validation
  22. Design an Online Chat Room with PHP and MySQL
More related feeds
Design+an+Online+Chat+Room+with+PHP+and+MySQLhttp://blogsearch.google.com/blogsearch_feeds?hl=en&q=Design+an+Online+Chat+Room+with+PHP+and+MySQL&ui=blg&ie=utf-8&num=10&output=rssFreelance Project | Yahoo Invisible Detecta Script
Installation of chatroom and that I can modify and add more as I go along 2. Online status, which means that each Reader will have a chatroom when entering the chatroom will show them online, when Busy , busy will show ...

Design an Online Chat Room with PHP and MySQL
Material Image, In this article, you will learn how to design and develop a simple online chat room with PHP and MySQL. Author: PHPreg.com Date: May 13, 2008.

All You Like » WordPress Theme Design - Rapidshare Download
Chat. AllYouLike Official Chatroom! BETA ... Chapter 3 uses the final XHTML and CSS mockup from Chapter 2 and shows you how to add WordPress PHP template tag code to it and break it down into the template pages a theme requires. ...

Chat Room Design with PHP and MySQL
In this article, you will learn how to design and develop a simple online chat room with PHP and MySQL. This tutorial explains every steps of the development, including both database design and PHP programming. Basic computer skills and ...

Chatroom Live Online Status | Freelance Arena
Chatroom Install/online Status. Hi, Looking for someone to install Flash chat version5.08 , as well make modifications, need so far 4 chats installed. Need to show status of my Readers as online, busy, offline. Also need the chat to ...

Chat Room Project by Rogge | Freelance Projects
The chat function must be 100% stable, bug free, and should be absolutely flood proof! i do not want anything that can be used to crash... (Budget: $30-250, Jobs: AJAX, Java, Javascript, PHP, Script Installation)

Best Scripts : Power Scripts A 4000.00 Value!::Full free download ...
This PHP & MySQL based photo album features include unlimited albums and photos, users and comments, automatically add and remove photos, thumbnail support, multilanguage and themes. Awesome PHP-Based Chatroom Script ...

design an online chat room with php and mysql
in this article, you will learn how to design and develop asimple online chat room with php and mysql. this tutorialexplains every steps of the development, including both databasedesign and php programming. basic computer skills and ...

Yahoo Messenger Tweaker
Chat Client, Booter, Boot, Yazak, Ymlite, Yahaven, Ytunnel, YTK, Yahelite, Pidgin, Room Booter, Lagg, Voice, Yahoo, Bots, Spam,Chat, Crack, Proxy, Pinoy Room Conquer, YmHook, Yhook, Yahoo Messenger, Yahoo Ace, No5, Scanner, Yahfox, ...

Flash Chat For Joomla & Community Builder by BigBox | Freelance ...
I need someone with Joomla & flash experience to create a chat room base on flash and php. I have the description of the project on the images i attached. (Budget: $250-750, Jobs: Flash, Joomla, PHP)

 


 

© 2008 sourceofarticles.com - All Rights Reserved