5. User Logon (login. php)
At the beginning, we said that the entry to the game is the index. php file. We have already installed the file, and naturally turn to the login process to start watching it.
As shown in the preceding example, we will not go into details about the code we have introduced. The difference is that the language file used is login.mo and there is a LOGIN constant. As follows:
define('INSIDE' , true);define('INSTALL' , false);define('LOGIN' , true);$InLogin = true;$xnova_root_path = './';include($xnova_root_path . 'extension.inc');include($xnova_root_path . 'common.' . $phpEx);includeLang('login');
The next step is the structure we mentioned earlier. We can see that the first branch we entered is the following code:
$ Parse = $ lang; $ Count = doquery ('select COUNT (*) as 'players' FROM {table} WHERE 1', 'users', true ); $ LastPlayer = doquery ('select' username' FROM {table} order by 'register _ time 'desc', 'users', true ); $ parse ['last _ user'] = $ LastPlayer ['username']; $ PlayersOnline = doquery ("select count (DISTINCT (id )) as 'onlinenow' FROM {table} WHERE 'onlinetime'> '". (time ()-900 ). "';", 'users', true); $ parse ['Online _ users'] = $ PlayersOnline ['onlinenow']; $ parse ['users _ amount '] = $ Count ['players']; $ parse ['servername'] = $ game_config ['game _ name']; $ parse ['Forum _ url'] = $ game_config ['Forum _ url']; $ parse ['passwordlost'] = $ lang ['passwordlost']; $ page = parsetemplate (gettemplate ('login _ body'), $ parse ); // Test pour prensid le nombre total de joueur et le nombre de joueurs connect bought if ($ _ GET ['ucount'] = 1) {$ page = $ PlayersOnline ['onlinenow']. "/". $ Count ['players']; die ($ page);} else {display ($ page, $ lang ['login']);}
It mainly obtains the number of registered users, the last registered users, and the current number of online users. The logon welcome page is displayed, including the user data obtained above.
Now, you can choose to register and switch to the previous chapter, or enter the user name and password for login.
1. Obtain records of this user from the database based on the input user.
2. If there is a record, use md5 to determine whether the user's password is correct
3. If the password is correct, check whether the user has chosen the Remember password function.
4. include database configuration file config
5. Setcookie, including the user name and password
6. Redirect to the frames. php file
In the previous several cases, the system prompts errors and stops the logon process. The message () function prompts are used.