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

Jul 13, 2016 am 10:24 AM
php Source code Web games

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

1

2

3

4

5

6

7

8

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:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

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

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

CakePHP Project Configuration

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

CakePHP Date and Time

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

CakePHP File upload

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

CakePHP Routing

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

Discuss CakePHP

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

How To Set Up Visual Studio Code (VS Code) for PHP Development

CakePHP Quick Guide CakePHP Quick Guide Sep 10, 2024 pm 05:27 PM

CakePHP Quick Guide

See all articles