Miscellaneous

  Home arrow Miscellaneous arrow Mini-Chat Tutorial
MISCELLANEOUS

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

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

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    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

    blog comments powered by Disqus

    MISCELLANEOUS ARTICLES

    - Oracle Database XE: Indexes and Sequences
    - Modifying Tables in Oracle Database XE
    - Oracle Database XE: Tables and Constraints
    - More on Oracle Databases and Datatypes
    - Oracle Database XE Datatypes: Datetime and L...
    - Oracle Database XE Datatypes: Character and ...
    - From Databases to Datatypes
    - Firefox 3.6.6 Released with Improved Plug-in...
    - Attention Bloggers: WordPress 3.0 Now Releas...
    - Reflection in PHP 5
    - Inheritance and Other Advanced OOP Features
    - Advanced OOP Features
    - Linux from Scratch V.6.6 Review
    - Linux Gaining in Strength
    - Install Slackware on Your Old PC


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap