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 / 4
    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!


    IBM DB2 Deep Compression ROI Tool

    The IBM DB2 Deep Compression ROI tool is designed for DBA’s and IT management personnel to perform a clinical analysis of the cost savings gained from the Storage Optimization feature of DB2 9 for Linux, UNIX and Windows. The feature, also known as Deep Compression, compresses data that lies within a database by up to 80% at times.
    FREE! Go There Now!


    NEW! Driving Business Success with Rational Process Library

    Join this webcast, to learn how the Rational Process Library can help with compliance issues, drive process improvement, and assist in service-oriented architecture (SOA) or Agile development. We will take a peek into the Rational Process Library with content around software and systems engineering (including RUP), operations and systems management, program and portfolio management, and asset and SOA governance.
    FREE! Go There Now!


    NEW! Application Development Tools for the Mainframe Developer

    You probably have thousands of lines of COBOL code loaded with business intelligence and being used to run your business, along with an army of developers maintaining these applications. Learn how to prepare your applications and developers so you can keep that competitive edge and move to a service-oriented architecture with the IBM Rational Enterprise Modernization solutions. Replay is available for 9 months.
    FREE! Go There Now!


    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 Rational Host Access Transformation Services (HATS) Toolkit V7.1

    Visit IBM developerWorks to download a free trial of the Rational Host Access Transformation Services (HATS) Toolkit. The HATS toolkit provides a set of plug-ins for the IBM Rational Software Delivery Platform to help you easily extend your legacy applications. HATS makes your 3270 and 5250 applications available as HTML through the most popular Web browsers, while converting your host screens to a Web look and feel and it also enables you to develop new Web, portal, and rich-client applications.
    FREE! Go There Now!


    NEW! Harnessing the power of SQL and Java for high performance data access

    Join this webcast to see how IBM Data Studio Developer and pureQuery can take the pain out of Java data access. uApplications developed using both Java and SQL have become a common requirement. Database connectivity using Java Database Connectivity (JDBC) to create an application is a multi-step tedious process, and tooling that covers both SQL and Java has been unavailable, until now. IBM Data Studio introduces the pureQuery platform: a high-performance, Java data access platform focused on simplifying the tasks of developing, managing, and optimizing database applications and services.
    FREE! Go There Now!


    NEW! IBM Rational AppScan Standard Edition V7.7

    Secure your Web applications with IBM Rational AppScan Standard Edition V7.7, previously known as Watchfire AppScan. This Web application security testing tool automates vulnerability assessments and scans and tests for common Web application vulnerabilities. Visit IBM developerWorks to download a free trial of IBM Rational AppScan Standard Edition V7.7.
    FREE! Go There Now!


    NEW! Integrating XML into Your Enterprise Using Data Federation

    XML has become a common way of storing business data as flat files and many data server vendors including IBM have provided ways to store this data within relational database systems. Increasingly collections of XML files are accessed like databases using an xQuery and other XML standard mechanisms. Businesses find the need to combine the traditional tabular structured data with XML formatted data. In this webcast, you’ll learn about IBM’s WebSphere Federation Server technology, which provides users with the ability to integrate these two data formats.
    FREE! Go There Now!


    NEW! Trial download: IBM Rational Manual Tester V7.0.1

    Try the latest version of IBM Rational Manual Tester V7.0.1 by downloading a free trial from IBM developerWorks. This manual test authoring and execution tool promotes test step reuse to reduce the impact of software change on testers and business analysts and addresses the needs of teams performing at least a portion of their testing manually.
    FREE! Go There Now!


    NEW! Using IBM Rational Developer for System z and IBM Rational ClearCase together to manage application development

    Whether you are creating new applications or modifying existing ones, managing integration of new components with traditional z/OS elements is a critical part of building and deploying modern applications. Listen to this webcast to see how IBM can help you optimize your development process using an IDE like Rational Developer for System z that integrates with management tools, such as ClearCase to manage your application development on mainframes.
    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-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek