PHP web game learning-Explanation of Xnova (ogame) source code (4)

Source: Internet
Author: User
This article mainly introduces the user logon page for interpreting the PHP web game Xnova (ogame) Source Code. For more information, see

This article mainly introduces the user logon page for interpreting the PHP web game Xnova (ogame) Source Code. For more information, see

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, as described above.

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.