Simulation of OICQ Implementation ideas and Core Programs (1)

Source: Internet
Author: User

Based on the needs of many netizens, I have dedicated my online chat on this simulated OICQ!

1. the user must register for login and save the following fields in the database userinfo:
No need to ask, This is the login user name, must be unique
Password Login Password
Nickname: the nickname of the user, that is, the name displayed.
Face stores the user avatar number, such as 01, representing/images/face/01.gif Avatar File
Onlinestatus indicates whether the user is online. It is set to 1 when the user logs in.
Currentdate the last time the user accesses/updates, used to determine whether the user is online

The structure of the 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)
);
The sender is the sender's name.
The receiver is the receiver's name.
Date is the time of the speech
Have you read readsign?
Body speech content

2. display the avatar of an 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 short message according to the Avatar :";
For ($ I = 0; $ I <$ onlinenumber; $ I ++)
{
If (! $ Onlineuser = mysql_fetch_array ($ onlineresult) break;
Echo "<a onclick = mm_openbrwindow ('shortalk. php? Talkto = ". $ onlineuser ['name']. "','". $ onlineuser ['name']. "', 'width = 300, Height = 250')> If ($ name = $ onlineuser ['name']) echo "border = 1 ";
Echo "Title = 'Code :". $ onlineuser ['name']. "\ n nickname :". $ onlineuser ['nickname']. "\ n Access :". $ onlineuser ['entertimes']. "'> </a> ";
}
?>

Onclick is used to pop up the dialog window for sending messages.Source codeSee

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.