Article source: PHP Century Network. According 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: Name No need to ask, this is the user name for login, it must be unique Password Login password NickName User nickname, which is the displayed name Face stores the number of the user's avatar. For example, 01 represents /images/face/01.gif. The avatar file OnlineStatus indicates whether the user is online. It is set to 1 when the user logs in. CurrentDate is the last access/update time of the user. It is used to determine whether the user is online. The structure of 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 the name of the sender, receiver is the name of the recipient, date is the time of the speech, readsign and whether the speech has been read. body speech content 2 Display the avatar of online users $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, send text messages according to the avatar: "; for($i=0;$i"; } ?> The onClick is used to pop up the dialogue window for sending messages. You can see it in the source code of the web page