Casual Articles
#1 in Business Subscribe Email Print

You are here: Home > Internet and Businesses Online > Web Development > Chat Room Design with PHP and MySQL

Tags

  • course
  • loginplease input
  • message records
  • simple online

  • Links

  • NordicTrack Equipment - The Good, Bad And The Ugly
  • Ameircan Obsession With Celebrity
  • Vegetables - Health Food Or Killers
  • Casual Articles - Chat Room Design with PHP and MySQL

    Free Website Developement Advice
    Do you need tips for developing your website? Are you a newbie, or are you experienced? It really doesn't matter, with the help of this course described in this article.The course supplies everything one needs to create a website, register it, and get it hosted on the internet. Quite possibly, your website could provide you with an unlimited income, depending on what you are aiming for.It will go into details about webpage creation, and formatting. It also teaches you how to insert images as well as text, and hyperlinks. This course really covers a l
    rds)=mysql_fetch_row($result);

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

    echo "

    <BR>";

    } //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);

    ?>

    </body>

    </html>

    4. speak.php

    <html>

    <head>

    <title>Speak</title>

    </head>

    <body>

    If ($words)

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

    mysql_select_db("abc"); //

    Learn How To Increase Adsense Pay - Strike Gold By Driving Quality Traffic To Your Website
    Do you know that you can keep those clicks happening on your adsense ads at your adsense website or blog?Read on to learn how to increase adsense pay by simply driving quality traffic to your adsense website or blog.Learn how to increase your adsense pay - relevant traffic is the key. Quality traffic means relevance. What this means is that you have to target a specific audience and write quality content only for that same audience. For example, if you are so much interested in toys, instead of creating one adsense website or blog for toys, y
    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

    speak.php

    Step 3: Write the code

    1. login.php (just a HTML form)

    <html>

    <head>

    <title>User Login</title>

    </head>

    <body>

    Please input your nickname and enter

    <br>

    <form action="main.php" method="post" target="_self">

    <input type="text" name="nick" cols="20">

    <input type="submit" value="login">

    </form>

    </body>

    </html>

    2. main.php

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

    ?>

    <html>

    <title>My Chat Room</title>

    <frameset rows="80%,*">

    <frame src="display.php" name="chatdisplay">

    <frame src="speak.php" name="speak">

    </frameset>

    </html>
    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.

    <html>

    <head>

    <title>Display Messages</title>

    <meta http-equiv="refresh" content="5;url=display.php">

    </head>

    <body>

    //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 "

    <BR>";

    } //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);

    ?>

    </body>

    </html>

    4. speak.php

    <html>

    <head>

    <title>Speak</title>

    </head>

    <body>

    If ($words)

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

    mysql_select_db("abc"); //

    Organic SEO The New Messiah For Webmasters
    Organic SEO seems to be the catch phrase of the moment. However, unlike many other linking tactics and strategies, this one actually works.What is Organic SEO or Organic Search Engine Optimization?Explained simply, it's where all your linking structures originates from the content up -- in other words, you let all your content created for your sites, blogs and articles do your link building for you.Actually, the answer is as simple as this article. You're probably experiencing one of the best examples of Organic SEO right this mom
    ions: 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

    speak.php

    Step 3: Write the code

    1. login.php (just a HTML form)

    <html>

    <head>

    <title>User Login</title>

    </head>

    <body>

    Please input your nickname and enter

    <br>

    <form action="main.php" method="post" target="_self">

    <input type="text" name="nick" cols="20">

    <input type="submit" value="login">

    </form>

    </body>

    </html>

    2. main.php

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

    ?>

    <html>

    <title>My Chat Room</title>

    <frameset rows="80%,*">

    <frame src="display.php" name="chatdisplay">

    <frame src="speak.php" name="speak">

    </frameset>

    </html>
    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.

    <html>

    <head>

    <title>Display Messages</title>

    <meta http-equiv="refresh" content="5;url=display.php">

    </head>

    <body>

    //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 "

    <BR>";

    } //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);

    ?>

    </body>

    </html>

    4. speak.php

    <html>

    <head>

    <title>Speak</title>

    </head>

    <body>

    If ($words)

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

    mysql_select_db("abc"); //

    Love Sports? An Exciting Sport Franchise May Be For You!
    Truth be told, starting your very own sports business may not as hard as you may think. In fact, a franchise business opportunity might be just what you need to get your foot into the door of a lucrative career in the sports industry.Consider for a moment the potential for sport franchises in today's marketplace. It goes without saying that a business that provides sports oriented products and services can attract consumers of all ages and backgrounds.Additionally, fitness and physical activity are both encouraged and promoted in today's society; thu
    type="submit" value="login">

    </form>

    </body>

    </html>

    2. main.php

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

    ?>

    <html>

    <title>My Chat Room</title>

    <frameset rows="80%,*">

    <frame src="display.php" name="chatdisplay">

    <frame src="speak.php" name="speak">

    </frameset>

    </html>
    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.

    <html>

    <head>

    <title>Display Messages</title>

    <meta http-equiv="refresh" content="5;url=display.php">

    </head>

    <body>

    //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 "

    <BR>";

    } //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);

    ?>

    </body>

    </html>

    4. speak.php

    <html>

    <head>

    <title>Speak</title>

    </head>

    <body>

    If ($words)

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

    mysql_select_db("abc"); //

    The Top Five Reasons Strategic Plans Fail
    "Most great plans aren't. They are just nice, high-level ideas."That's how one of our survey respondents answered our question, "What are the top three obstacles that prevent great plans from reaching effective implementation?" Despite the universal chatter around the need to be "strategic", and the untold hours spent developing strategic plans, it appears that they don't work nearly often enough. And based on the spirited responses we got from the generous folks who answered our survey, it seems that many have been involved in a strategic plan that failed.
    ml>

    <head>

    <title>Display Messages</title>

    <meta http-equiv="refresh" content="5;url=display.php">

    </head>

    <body>

    //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 "

    <BR>";

    } //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);

    ?>

    </body>

    </html>

    4. speak.php

    <html>

    <head>

    <title>Speak</title>

    </head>

    <body>

    If ($words)

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

    mysql_select_db("abc"); //

    Blogging Numbers - An Overview
    It is easy to see how quickly the phenomenon of blogging has exploded on the Internet in recent years. Ah, but what are the hard numbers about the number of blogs and who is using them?The relative newness of blogging makes it somewhat difficult to track specific trends and topics, but there are some statistics about Internet blogging that can be observed from information obtained by search engines and random surveys. Also hampering the statistics are the true definition of a blog, and the fact that not all blogs are standalone or able to be measured as a s
    rds)=mysql_fetch_row($result);

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

    echo "

    <BR>";

    } //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);

    ?>

    </body>

    </html>

    4. speak.php

    <html>

    <head>

    <title>Speak</title>

    </head>

    <body>

    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

    <form action="speak.php" method="post" target=" _self">

    <input type="text" name="words" cols="20">

    <input type="submit" value="Speak">

    </form>

    </body>

    </html>
    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, :)

    HTTP = HTML link (for blogs, profiles,phorums):
    <a href="http://www.casualarticles.com/article/87314/casualarticles-Chat-Room-Design-with-PHP-and-MySQL.html">Chat Room Design with PHP and MySQL</a>

    BB link (for phorums):
    [url=http://www.casualarticles.com/article/87314/casualarticles-Chat-Room-Design-with-PHP-and-MySQL.html]Chat Room Design with PHP and MySQL[/url]

    Related Articles:

    Email Marketing Manners 101: Clearing Your Inbox By Forwarding Email Messages To Someone Else

    From Ebay Zero to Power-Selling Hero: How To Learn New Tricks Without Spending

    Longshot Method of Obtaining Inbound Links Without Exchanges

    Bookmark it: del.icio.us digg.com reddit.com netvouz.com google.com yahoo.com technorati.com furl.net bloglines.com socialdust.com ma.gnolia.com newsvine.com slashdot.org simpy.com shadows.com blinklist.com