PHP Web Game Learning Xnova (Ogame) source Interpretation (iv) _php example

Source: Internet
Author: User
V. User Login (login.php)

At the beginning, we said that the entrance to the game is index.php file; we've installed it, and naturally turned to the login process to start looking.

As usual is a section of the code we have introduced, we will no longer speak in detail; the difference is that the language file used is Login.mo, and there is a login constant. As follows

Define (' INSIDE ', true);d efine (' INSTALL ', false);d efine (' LOGIN '  


And then again, the structure we talked about earlier, the first branch we saw was 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 ' DES  C ', ' 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 Prendre le nombre total de joueur et le nombre de joueurs connect 閟 if ($_get[' ucount '] = = 1) {$page = $PlayersOnline [' Onli Nenow ']. " /". $Count [' players ']; Die ($page);} else {display ($page, $lang [' Login ']);} 

The main is to obtain the number of registered users, the last registered users, the current number of online, and display the landing welcome page, including the previously obtained user data.
OK, now the user can choose to register and turn to the previous chapter process, or enter a username and password into the login process.

1. Obtain this user's record from the database based on the user entered.
2. If there is a record, use MD5 to determine if the user's password is correct
3. If the password is correct, see if the user has chosen to remember the password function, followed by
4. Include database configuration file config
5. Setcookie, there is a user name, password, etc.
6. Redirect to frames.php file

Some of the previous judgments, there will be some error message, and the end of the login process, using the message () function hint, the previous also said.

  • 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.