Home > Backend Development > PHP Tutorial > Analyze the registration and login mechanism of ECMall_PHP tutorial

Analyze the registration and login mechanism of ECMall_PHP tutorial

WBOY
Release: 2016-07-13 10:33:52
Original
936 people have browsed it

ecmall registration process index.php?app=member&act=register.

First of all, app is member and act is register method.

index.php. Started through ecmall's startup method, which mainly includes eccore/ecmall.php. The startup method includes eccore/controller/app.base.php and eccore/model/model.base.php basic classes, through

$app = isset($_REQUEST['app']) ? trim($_REQUEST['app']) : $default_app;
$act = isset($_REQUEST['act']) ? trim($_REQUEST['act']) : $default_act; 
Copy after login

to get app and act.

If it is registration, act=member then

$app_class_name = ucfirst($app) . 'App';
/* 实例化控制器 */
$app = new $app_class_name();
Copy after login

Here $app = new MemberApp, calling the register method in the MemberApp class. In the register method, get the registration information. Through the ms method in global.lib.php.

include(ROOT_PATH . '/includes/passport.base.php');
include(ROOT_PATH . '/includes/passports/' . MEMBER_TYPE . '.passport.php'.regissword.php
Copy after login

And the following program in the ms() function in register

include(ROOT_PATH . '/includes/passports/' . MEMBER_TYPE . '.passport.php');
$class_name  = ucfirst(MEMBER_TYPE) . 'Passport';
$ms = new $class_name();
Copy after login

Contains the DefaultPassport class in default.passport.php, and it inherits BasePassport, which has a few lines of code

$user_class_name = ucfirst($this->_name) . 'PassportUser';
$this->user = new $user_class_name();
Copy after login

So this is where $this -> user in the program comes from.

$user_class_name is actually the DefaultPassportUser class in includes/passports/default.passport.php. And he extends BasePassportUser, and he calls the _local_add() method in BasePassportUser. The _local_add() method calls the The initialization data in member.model.php is processed in the database through the function add($data, $compatible = false) method under the BaseModel class in eccore/model/model.base.php. This completes the registration function.

    /**
     *  添加一条记录
     *
     *  @author Garbin
     *  @param  array $data
     *  @return mixed
     */
    function add($data, $compatible = false)
    {
        if (empty($data) || !$this->dataEnough($data))
        {
            return false;
        }
        $data = $this->_valid($data);
        if (!$data)
        {
            $this->_error('no_valid_data');
            return false;
        }
        $insert_info = $this->_getInsertInfo($data);
        $mode = $compatible ? 'REPLACE' : 'INSERT';
        $this->db->query("{$mode} INTO {$this->table}{$insert_info['fields']} VALUES{$insert_info['values']}");
        $insert_id = $this->db->insert_id();
        if ($insert_id)
        {
            if ($insert_info['length'] > 1)
            {
                for ($i = $insert_id; $i < $insert_id + $insert_info['length']; $i++)
                {
                    $id[] = $i;
                }
            }
            else
            {
                /* 添加单条记录 */
                $id = $insert_id;
            }
        }
        return $id;
    }
Copy after login

Login mechanism

The process of logging in to the ecmall e-commerce system is actually very complicated. First, he calls the login page by calling malldefaultlogin.html. The calling program is implemented by calling the login method of appfrontend.base.php.

The if (!IS_POST) program represents the display of the login page, which is processed by calling $this->display('login.html'). The login.html page of ecmall mainly has the following variables to be passed. The three variables user_name, password, and captcha are used for login verification. $user_name = trim($_POST['user_name']) and $password = $_POST['password'] are mainly used to accept usernames and passwords. Login verification is performed by connecting to the login center $ms =& ms() to call $ms->user->auth($user_name, $password).

The function &ms() in the file includes/global.lib.php is used to connect to the login center. include(ROOT_PATH . '/includes/passports/' . MEMBER_TYPE . '.passport.php'); $class_name = ucfirst(MEMBER_TYPE) . 'Passport';$ms = new $class_name();Here is to declare the login object .

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/752381.htmlTechArticleecmall registration process index.php?app=memberact=register. First of all, app is member and act is register method. index.php. Started through the startup method of ecmall, which mainly includes eccore/e...
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