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.
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.
Prepare such a buffer page and put it in upload/template/default/touch/member/ In the page of register.htm
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('&', '&', dreferer());}--> <input type="hidden" id="referer" name="referer" value="$dreferer" /> <input type="hidden" name="activationauth" value="{if $_GET[action] == 'activation'}$activationauth{/if}" /> <input type="hidden" name="agreebbrule" value="$bbrulehash" id="agreebbrule" checked="checked" /> <!--{if $_G['setting']['sendregisterurl']}--> <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.
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 = $('#hash').val(); var referer = $('#referer').val(); $.ajax({ type:'POST', url:"member.php?mod={$_G[setting][regname]}&mobile=2" +'&inajax=1', data:{ "handlekey":"registerform", "inajax" : 1, "regsubmit" :"yes", "formhash":hash, "referer" :referer }, dataType:'xml' }) .success(function(s) { popup.open(s.lastChild.firstChild.nodeValue); evalscript(s.lastChild.firstChild.nodeValue); }) .error(function() { window.location.href = obj.attr('href'); 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
We register a ceshi123 account
Test post
##Why not useuc_user_register The reason for this method to register users
uc_user_register is used to register users directly, all the following information will not be obtained
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!