Miscellaneous
  Home arrow Miscellaneous arrow Mini-Chat Tutorial
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Forums Sitemap 
Dedicated Servers  
Download TestComplete 
JMSL Numerical Library 
IBM® developerWorks
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MISCELLANEOUS

Mini-Chat Tutorial
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 9
    2002-07-24

    Table of Contents:
  • Mini-Chat Tutorial
  • Basic Printing
  • Improving
  • Final Script

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Mini-Chat Tutorial


    (Page 1 of 4 )

    This tutorial is about my mini-chat script. It's not really a chat, since dialogs are updated only when page refreshes. It is the first tutorial of a series for some development techniques. Right now, I will focus on explaining how I managed the building of this mini-chat.

    By : greggory

    First thing to ask is what is chatting? So what do I need to Code? Basicly, a chat is a set of messages posted by someone, and in the order they've been posted. So we can write a first form, having two fields 'login' and 'message'. Then, we have to append it to a file, or better, a database. The details for the form syntax may be found in Matt's Tutorial.

    <html>
    <head>
    <title>Mini Chat Sample</title>
    </head>
    <body>
      <form method="post"><br>
      Login:<input type="text" name="login" size="6"><br>
      Message:<input type="text" name="message" size="10"><br>
      <input type="submit" value="Send"><br>
      </form>
    </body>
    </html>

    We also need, of course, the DB schema and a function to insert to message.

    <?php
    /*
    CREATE TABLE MINICHAT (
      LOGIN varchar(20) NOT NULL default '',
      MESSAGE varchar(255) NOT NULL default '',
      ITSTIME varchar(10) NOT NULL default ''
    );
    */

    // Add message into minichat
    function addMessage$login$message ) {

       
    $login mysql_escape_stringstrip_tags$login ) );
       
    $message mysql_escape_stringstrip_tags$message'&lt;a&gt;&lt;b&gt;&lt;i&gt;&lt;u&gt;') );
       
    mysql_query"INSERT INTO MINICHAT ( ITSTIME, LOGIN, MESSAGE ) VALUES ( "'".time()."''".$login."','".$message."' )");
    }

    // Message Posted ?
    if ( isset( $_POST['msg'] )) {
       addMessage( $_POST['login'], $_POST['msg'] );
    }
    ?>

    More Miscellaneous Articles
    More By Codewalkers


       · test
       · I modified the Mini-Chat. I added:- Example for database connection- Different...
       · 
       · I read the disclaimer and also the authors terms, but I didnt seem to find anything...
     

    MISCELLANEOUS ARTICLES

    - Stopping CSRF Attacks in Your PHP Applicatio...
    - Quick and Dirty AJAX Tutorial
    - Flickr Puzzle Mashup
    - The PAVISE of Security
    - Creating a CAPTCHA with PHP
    - Sending SMS Thru HTTP
    - The Postal Fix - Part 2
    - Adding Mail with Exim
    - The Postal Fix - Part 1
    - Create Your Own Custom API
    - Adding Drop Shadows with PHP
    - Writing a Basic Authentication System in PHP
    - Overlapping Images with GD
    - Using Sockets in PHP
    - Dynamic CSS with PHP






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway