Implementation ideas and core procedures for simulating OICQ (1)_PHP tutorial

WBOY
Release: 2016-07-21 16:06:41
Original
892 people have browsed it

According to the needs of many netizens, I specially dedicated this online chat thing that simulates OICQ to everyone!

1 The user must register and log in, and save the following fields in the database userinfo
Name No need to ask, this is the user name for login, it must be unique
Password login password
NickName User Nickname, that is, the displayed name
Face stores the number of the user's avatar, such as 01, which represents /images/face/01.gif avatar file
OnlineStatus indicates whether the user is online, set to 1 when the user logs in
CurrentDate The last access/update time of the user, used to determine whether the user is online

The structure of chat record forumtalk is
CREATE TABLE forumtalk (
id int(11) NOT NULL auto_increment,
sender varchar(20) NOT NULL,
receiver varchar(20) NOT NULL,
date int(11) DEFAULT '0' NOT NULL,
readsign tinyint(4) DEFAULT '0' NOT NULL ,
body varchar(200) NOT NULL,
PRIMARY KEY (id),
UNIQUE id_2 (id),
KEY id (id)
);
where sender is sending The name of the person
receiver is the name of the recipient
date is the time of the speech
readsign whether the speech has been read
body the content of the speech

2 Display the avatar of the online user
$onlineresult = mysql_query("select Name,NickName,Face,EnterTimes from userinfo where OnlineStatus=1 and CurrentDate >".(date("U")-120));
$onlinenumber = mysql_num_rows($onlineresult);
echo "Welcome, there are: ".$onlinenumber." friends online, click the avatar to send a text message:";
for($i=0;$i<$onlinenumber; $i++)
{
if(!$onlineuser = mysql_fetch_array($onlineresult))break;
echo "if($name == $onlineuser['Name'])echo "border=1 ";
echo " title='Codename:". $onlineuser['Name']."nNickname:".$onlineuser['NickName']."nVisit:".$onlineuser['EnterTimes']."'>
";
}
?>

The onClick is used to pop up the dialog window for sending messages. You can see it in the source code of the web page.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315344.htmlTechArticleAccording to the needs of many netizens, I specially dedicated this online chat that simulates OICQ to everyone! 1 The user must register and log in, and save the following fields in the database userinfo...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template