Discussion Board Code
  Home arrow Discussion Board Code arrow MiniChat
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  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
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? 
DISCUSSION BOARD CODE

MiniChat
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 5
    2002-07-18

    Table of Contents:

    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


    A MySQL-based mini-chat to put as a block on your pages.

    By : greggory

    <?php
    // Contains db constants
    require "cst.inc";

    /*
    CREATE TABLE MINICHAT (
    NB tinyint(4) NOT NULL auto_increment,
    LOGIN varchar(20) NOT NULL default '',
    MESSAGE varchar(255) NOT NULL default '',
    ITSTIME varchar(10) NOT NULL default '',
    ) TYPE=MyISAM;
    */

    // Number of messages to print
    define( "_NB_MSGS_", 10 );

    // Connect
    mysql_connect( $db_hostname, $db_username, $db_password );
    mysql_selectdb( $db_database );

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

    @setcookie( "minichatlogin", strip_tags( $login ) );

    $login = $_COOKIE['minichatlogin'] ? $_COOKIE['minichatlogin'] :
    mysql_escape_string( strip_tags( $login ) );
    $message = mysql_escape_string( strip_tags( $message, '<a><b><i><u>') );
    mysql_query( "INSERT INTO MINICHAT ( NB, ITSTIME, LOGIN, MESSAGE ) VALUES ( "
    ._NB_MSGS_.", '".
    time()."', '".$login."','".$message."' )" );
    mysql_query( "UPDATE MINICHAT SET NB=NB-1" );
    mysql_query( "DELETE FROM MINICHAT WHERE NB < 1" );
    }

    // Returns messages
    function getMessages() {
    $rs = mysql_query( "SELECT * FROM MINICHAT ORDER BY NB" );

    $ret = Array();
    while ( $msg = mysql_fetch_array( $rs )) {
    $ret[] = date( 'h:m', $msg['ITSTIME'] )." ".$msg['LOGIN']." >".$msg['MESSAGE'];
    }

    return $ret;
    }

    // Prints mini chat
    function miniChat() {

    $msgs = getMessages();
    @reset( $msgs );

    echo '<form method="post">
    <table border="0" bgcolor="#000000" cellpadding="1">
    <tr><td>
    <table border="0" bgcolor="#ffffff" cellpadding="1">
    ';

    while ( list(,$msg) = each( $msgs ))
    echo "<tr><td>$msg</td></tr>";

    if ( !$_COOKIE['minichatlogin'] ) {
    if ( !$_POST['login'] )
    echo '<tr><td>Login:<input type="text" name="login" size="6"></td></tr>';
    else
    echo '<input type="hidden" name="login" value="'.$_POST['login'].'">';
    }
    echo '
    <tr><td><input type="text" name="msg" size="10"></td></tr>
    <tr><td align="center"><input type="submit" value="Send"></td></tr>
    </table></tr></td></table></form>';
    }


    // Message Posted ?
    if ( isset( $_POST['msg'] )) {
    addMessage( $_POST['login'], $_POST['msg'] );
    }
    ?>
    <html>
    <head>
    <title>Mini Chat Sample</title>
    </head>
    <body>
    <center>
    <?php miniChat(); ?>
    <hr>
    <a href="mailto:greggory@free.fr">Contact</a>
    </center>
    </body>
    </html>
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Discussion Board Code Articles
    More By Codewalkers

     

    IBM® developerWorks developerWorks - FREE Tools!


    NEW! Download IBM WebSphere Portal V6.1 beta code

    Download the IBM WebSphere Portal V6.1 beta code and learn more about the rich features and enhancements in IBM WebSphere Portal V6.1. WebSphere Portal provides a composite application or business mashup framework and the advanced tooling needed to build flexible, SOA-based solutions, and scalability to meet the needs of any size organization.
    FREE! Go There Now!


    NEW! Evaluate IBM Rational Software Analyzer V7.0

    Download a free trial version of IBM Rational Software Analyzer Developer Edition V7.0 to identify bug defects earlier in the software development cycle. Rational Software Analyzer is an extensible software development solution that reduces the expense of bug-fixes by enabling static analysis code reviews and bug identification very early in the development cycle.
    FREE! Go There Now!


    NEW! Hello World: Monitor a simple business process using WebSphere Business Monitor V6.0.2

    This tutorial shows new users of IBM WebSphere Business Monitor Version 6.0.2 how to perform the "Hello World" equivalent for monitoring business process applications. It is intended to help you get familiar with the capabilities of the product.
    FREE! Go There Now!


    NEW! Improve your build process with IBM Rational Build Forge, Part 1: Create a continuous build and integration environment

    Learn how to implement a build management system that uses and extends your existing automation technologies. This tutorial shows, step-by-step, how to install and configure IBM Rational Build Forge to manage builds for Jakarta Tomcat from source code.
    FREE! Go There Now!


    NEW! Krugle, developerWorks, and code search

    Ken Krugler, co-founder of code search company Krugle, and Laura Merling, vice president of Marketing and Business Development for Krugle, join to talk about the ins and outs of code search and what it means as a new feature for developerWorks users.
    FREE! Go There Now!


    NEW! Rational Build Forge Express eKit

    Rational Build Forge Express Edition is an automation framework that packages the latest enterprise-grade technologies into a reliable, flexible and robust configuration designed and priced specifically for small to midsize businesses. The new Rational Build Forge Express eKit provides you with valuable resources – including a case study, podcast, demo, and articles – to help you increase staff productivity, compress development cycles and deliver better software, fast.
    FREE! Go There Now!


    NEW! Test terminal-based applications with Rational Functional Tester

    Regression testing -- in which code is thoroughly tested to ensure that changes have not produced unexpected results -- is an important part of any development process. But many testing environments neglect the terminal-based applications that still form the backbone of many industries. In this tutorial, you'll learn how the Rational Functional Tester Extension for Terminal-Based Applications works with other Rational Functional Tester to help test terminal-based applications quickly and easily.
    FREE! Go There Now!


    NEW! Trial download: IBM Lotus Forms V3.0

    Get a free trial download of IBM Lotus Forms V3.0 (formerly Workplace Forms), which provides a zero-footprint eForms solution to help you automate and move forms-based business processes off the desktop and onto the Web. With Lotus Forms, you can extend applications beyond the firewall by creating a single electronic form document ready for use in both thick and Web 2.0 thin client format.
    FREE! Go There Now!


    NEW! Understanding Web application security challenges

    As businesses grow increasingly dependent upon Web applications, these complex entities grow more difficult to secure. Most companies equip their Web sites with firewalls, Secure Sockets Layer (SSL), and network and host security, but the majority of attacks are on applications themselves – and these technologies cannot prevent them. This paper explains what you can do to help protect your organization, and it discusses an approach for improving your organization’s Web application security.
    FREE! Go There Now!


    NEW! Webcast: Application security testing and Web compliance

    Join the IBM Watchfire team for an informative discussion on techniques and best practices to proactively manage Web application security and how to effectively build application security testing into the software development lifecycle (SDLC). In this Software Delivery Platform webcast you will learn: How to better understand potential web application security vulnerabilities, best practices and how to effectively integrate application security testing into the software development lifecycle, the importance of detecting and removing software vulnerabilities during application development.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    DISCUSSION BOARD CODE ARTICLES

    - phpBB Google Sitemap XML generator v2.1
    - myPHPWiKi
    - Simple Shoutbox 1.3
    - Chipmunk Board
    - TagIt! Tagboard v2.1.B Build 2 - UPDATED 11....
    - Internal Mail System
    - phpAdBoard
    - Super Simple Discussion 4 sysadmins
    - Powerbox Version 0.2
    - SXMB
    - J.A.G. (Just Another Guestbook)
    - PowerBox
    - TagIt! Tagboard
    - Tom's Corkboard
    - MiniChat





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 8 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek