The chat room can run in a complete and free way. you can enter the room without a password or keep your chat status. the advantage is: freedom, which is very suitable for tourists! Another method is to register a chat room. every person who enters the chat room must enter his/her own
The chat room can run in a complete and free way. you can enter the room without a password or keep your chat status. the advantage is: freedom, which is very suitable for tourists! Another method is to register a chat room. every user who enters the chat room must enter his/her username and password! Strengths: it fully reflects the personality and is very suitable for old friends. what do they say will not be maliciously infringed on applications? my chat room app registration method!
Registration usually adopts two methods:
1. Register before chatting
2. active registration
Then modify your materials in it! I use 2nd methods !! The username of each new chat user will be automatically retained to the database. you must enter an accurate password for the next login!
The following is the judgment part! This program applies the text database!
//
//
//
//
//
// Enter the login parameter
If (= 'enter ')
{
// Current time in seconds
= Date ('u ');
// Lock the number of online users file to prevent simultaneous correction of the same file
While (file_exists ())
{
If (! File_exists ())
{
Break;
}
}
// Create a temporary file
Fclose (fopen (, 'w '));
// Read the information of online users and registered users: password, nickname, and update time
= File ();
= File ();
// Mark used to determine whether the login is successful
= 0;
// Determine the user name. The password is incorrect. the user name cannot be blank or exceed 10 characters. the password cannot exceed 20 characters.
If (= '') | (strlen ()> 10) | (strlen ()> 20 ))
{
Print ('No nickname or long password ');
// Login failed
= 1;
// Delete a temporary file
Unlink ();
}
Else
{
// Check whether someone has registered or the password is incorrect.
= 0;
For (= 0 ;();)
{
// Split
= Split (, 99 );
// Find the registered user name
If (=)
{
// The tag has been found.
= 1;
// Is the password correct?
If (! =)
Print ('wrong password! ');
// Login failed
= 1;
Unlink ();
Break;
}
Else
{
// Old user login successful
= 0;
Break;
}
}
}
// If the user name is not found, register it.
If (!)
{
// Retain the user name and password
= Fopen (, 'A ');
Fputs (,'');
Fclose ();
// New user login successful
= 0;
}
}
}
If (!)
{
// Update the list of online users
= Fopen (, 'w ');
// Determine whether it is already in, just refresh the page
= 0;
For (= 0 ;();)
{
= Split (, chop (), 99 );
If (=)
{
// Update the tag
= 1;
Fputs (,);