According to the needs of many netizens, I specially dedicated this online chat item that simulates OICQ on my site 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 username used for login and must be unique
Password Login Password
NickName User nickname, that is, the displayed name
Face stores the user's avatar number, such as 01, which represents /images/face/ avatar file
OnlineStatus The flag of whether the user is online is set to 1 when the user logs in.
CurrentDate The last time the user accessed/updated is used to determine whether the user is online
The structure of the chat history forum talk 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 the sender's Name
The receiver is the name of the recipient
date is the time to speak
readsign Have you read the speech
body speech content
2 Show 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, a total of:".$onlinenumber." A friend online, send a message by avatar:";
for($i=0;$i<$onlinenumber;$i++)
{
if(!$onlineuser = mysql_fetch_array($onlineresult))break;
echo "<a onClick=MM_openBrWindow('?talkto=".$onlineuser['Name']."','".$onlineuser['Name']."','width=300,height=250')><img src='images/face/".$onlineuser['Face'].".gif' width=20 height=20 ";
if($name == $onlineuser['Name'])echo "border=1 ";
echo " title='code:".$onlineuser['Name']."\nNickname:".$onlineuser['NickName']."\nVisit:".$onlineuser['EnterTimes']."'></a>";
}
?>
The onClick is used to pop up the conversation window for sending messages. You can see it in the source code of the web page.
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 username used for login and must be unique
Password Login Password
NickName User nickname, that is, the displayed name
Face stores the user's avatar number, such as 01, which represents /images/face/ avatar file
OnlineStatus The flag of whether the user is online is set to 1 when the user logs in.
CurrentDate The last time the user accessed/updated is used to determine whether the user is online
The structure of the chat history forum talk 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 the sender's Name
The receiver is the name of the recipient
date is the time to speak
readsign Have you read the speech
body speech content
2 Show 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, a total of:".$onlinenumber." A friend online, send a message by avatar:";
for($i=0;$i<$onlinenumber;$i++)
{
if(!$onlineuser = mysql_fetch_array($onlineresult))break;
echo "<a onClick=MM_openBrWindow('?talkto=".$onlineuser['Name']."','".$onlineuser['Name']."','width=300,height=250')><img src='images/face/".$onlineuser['Face'].".gif' width=20 height=20 ";
if($name == $onlineuser['Name'])echo "border=1 ";
echo " title='code:".$onlineuser['Name']."\nNickname:".$onlineuser['NickName']."\nVisit:".$onlineuser['EnterTimes']."'></a>";
}
?>
The onClick is used to pop up the conversation window for sending messages. You can see it in the source code of the web page.