search
HomeCMS TutorialDiscuzHow discuz implements automatic registration and login

How discuz implements automatic registration and login

May 03, 2020 pm 09:38 PM
discuzregister log in

Functions implemented in this article:

1. Enter the forum from the original system to automatically log in and register

2. Implement pop-up boxes on this page without jumping

3.js directly initiates a registration request when the page is loaded

This function was previously handled by the uc_user_register function, but today it will be used when developing user space problem appear.

Project requirements

Add a forum to our original system, but user information needs to be shared.

Implementation method: Bring the user information of the original system when entering the forum, and then get the information from the forum and register directly.

Enter the forum from the original system to automatically register and log in

Prepare such a buffer page and put it in upload/template/default/touch/member/ In the page of register.htm

How discuz implements automatic registration and login

then we need to put the original registration code into upload/template/default /touch/member/register.htm

The reason for putting this code is thatdsicuzThere will be many parameter restrictions when submitting the form, we can just keep it as it is.

<form method="post" autocomplete="off" name="register" id="registerform" action="member.php?mod={$_G[setting][regname]}&mobile=2">
   <input type="hidden" name="regsubmit" value="yes" />
   <input type="hidden" id="hash" name="formhash" value="{FORMHASH}" />
   <!--{eval $dreferer = str_replace(&#39;&&#39;, &#39;&&#39;, dreferer());}-->
   <input type="hidden" id="referer" name="referer" value="$dreferer" />
   <input type="hidden" name="activationauth" value="{if $_GET[action] == &#39;activation&#39;}$activationauth{/if}" />
   <input type="hidden" name="agreebbrule" value="$bbrulehash" id="agreebbrule" checked="checked" />
   <!--{if $_G[&#39;setting&#39;][&#39;sendregisterurl&#39;]}-->
   <input type="hidden" name="hash" value="$_GET[hash]" />
   <!--{/if}-->
   <!--{if $secqaacheck || $seccodecheck}-->
   <!--{subtemplate common/seccheck}-->
   <!--{/if}-->
   </div>
</form>

Then we need to directly send a request when the page is loaded, just add the following code.

Implement the pop-up box on this page, without jumping, and directly initiate a registration request when loading

The function implemented by this js code: directly initiate a registration request when the page is loaded, and then return the information , displayed directly on this page instead of jumping to another page

<script>
    var hash = $(&#39;#hash&#39;).val();
    var referer = $(&#39;#referer&#39;).val();
    $.ajax({
        type:&#39;POST&#39;,
        url:"member.php?mod={$_G[setting][regname]}&mobile=2" +&#39;&inajax=1&#39;,
        data:{
            "handlekey":"registerform",
            "inajax" : 1,
            "regsubmit" :"yes",
            "formhash":hash,
            "referer" :referer
        },
        dataType:&#39;xml&#39;
    })
        .success(function(s) {
            popup.open(s.lastChild.firstChild.nodeValue);
            evalscript(s.lastChild.firstChild.nodeValue);
        })
        .error(function() {
            window.location.href = obj.attr(&#39;href&#39;);
            popup.close();
        });
</script>

The last step required at this time is what form to use to transmit it from the original system. This method is not provided here. I will make a simulated data.

Add your own code according to the comments in the upload/source/module/member/member_register.php method on_register

How discuz implements automatic registration and login

Test the effect

We register a ceshi123 account

How discuz implements automatic registration and login

Test post

How discuz implements automatic registration and login

##Why not useuc_user_register The reason for this method to register users

If

uc_user_register is used to register users directly, all the following information will not be obtained

How discuz implements automatic registration and login

The above is the detailed content of How discuz implements automatic registration and login. For more information, please follow other related articles on the PHP Chinese website!

Statement
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 AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software