Home > Backend Development > PHP Tutorial > Xnova (ogame) source code interpretation for PHP web game learning (4)_PHP tutorial

Xnova (ogame) source code interpretation for PHP web game learning (4)_PHP tutorial

WBOY
Release: 2016-07-13 10:24:17
Original
1022 people have browsed it

5. User login (login.php)

At the beginning, we said that the entrance to the game is the index.php file; now that we have installed it, we naturally turn to the login process and start watching.

As usual, the previous section is a piece of code that we have introduced in advance, so we will not go into details; 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'); 
Copy after login


Next is the structure we talked about before. The branch we entered for the first time 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 prendre le nombre total de joueur et le nombre de joueurs connect閟
if ($_GET['ucount'] == 1) {
 $page = $PlayersOnline['onlinenow']."/".$Count['players'];
 die ( $page );
} else {
 display($page, $lang['Login']);
} 
Copy after login

Mainly to obtain the number of registered users, the last registered users, and the current number of online users; and display the login welcome page, including the user data obtained previously.
Okay, now the user can choose to register and go to the previous chapter process, or enter the username and password to go to the login process.

1. First obtain the user’s record from the database based on the entered 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 selected the remember password function, which will be used later
4. include database configuration file config
5. Setcookie, which contains username, password, etc.
6. Redirect to frames.php file

If the first few judgments are correct, some error messages will appear and the login process will end. The message() function prompt will be used, as mentioned before.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825515.htmlTechArticle5. User login (login.php) At the beginning, we said that the entrance to the game is index.php file; we have installed it, so naturally we turn to the login process and start watching. As usual...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template