Simple Php+mysql Chat Room implementation method (with source code) _php instance

Source: Internet
Author: User
Tags setcookie

A simple php+mysql chat room implementation method is described in this paper. Share to everyone for your reference, specific as follows:

The procedures described here are divided into 8 files:

Frameset frames page: index.php

Show Chat Room content page: show.php

User Login page: login.php

User Speaking page: speak.php

Database configuration file: config.php

Page beautification style: Style.css

Database files: Chat.sql

Speech Expression Package: face/

The following are described separately:

First, the database documents Chat.sql as follows:

SET foreign_key_checks=0; 
--------------------------------Table structure for ' chat '------------------------------DROP Table IF EXISTS ' chat '; CREATE TABLE ' chat ' (' chtime ' datetime default NULL, ' Nick ' char () not NULL, ' words ' char ($) default NULL, ' Face
' Int (one) default NULL engine=innodb default charset=gb2312; --------------------------------Records of chat------------------------------INSERT into chat VALUES (' 2013-03-21 04
: 15:14 ', ' smiling ', ' Test show speak ', ' 3 ');
INSERT into chat VALUES (' 2013-03-21 04:46:26 ', ' smiling ', ' time has a problem, ', ' 5 '); INSERT into chat VALUES (' 2013-03-21 04:47:28 ', ' php novice ', ' novice coming up.
', ' 1 ');
INSERT into chat VALUES (' 2013-03-21 04:55:19 ', ' php novice ', ' show Right ', ' 6 ');
INSERT into chat VALUES (' 2013-03-21 17:12:47 ', ' php novice ', ' Show time correctly ', ' 5 '); INSERT into chat VALUES (' 2013-03-21 17:23:19 ', ' php novice ', ' time is displayed correctly.
', ' 7 ');
INSERT into chat VALUES (' 2013-03-21 17:23:29 ', ' php novice ', ' haha ', ' 1 '); INSERT into chat VALUES (' 2013-03-22 08:28:00 ', ', ' and see again today.)

 ', ' 3 ');

Second, the frame page is as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 frameset//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd" >
 
 

Third, the user landing page login.php as follows:

 

Four, the user statements page speak.php as follows:

 

Five, show chat room content page show.php as follows:

<?php require_once (' config.php ');?> <?php if ($words) {$query = INSERT into chat (chtime,nick,words,face) Values (now (), ' $nick ', ' $words ', ' $face ');/INSERT SQL statement mysql_query ($query, $link _id); Send a message to the database header ("refresh:0; Url= ' show.php '); ?>  

Full instance code click here to download the site.

I hope this article will help you with the PHP program design.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.