Home  >  Article  >  Backend Development  >  Common function implementation processes in PHP development

Common function implementation processes in PHP development

藏色散人
藏色散人forward
2019-12-11 17:48:344016browse

1. PC website login

1. Obtain and filter the username, password and verification code submitted by the user

2. Verify whether the verification code submitted by the user is consistent with the verification code in the session

3. Verify whether the user name exists

4. Obtain the password based on the user name and verify whether the password is Consistent

5. If the password is consistent, the login is successful and jumps to the corresponding home page

Image:

Common function implementation processes in PHP development

##2. PC website registration

1. Ajax obtains the user name and mobile phone number to be registered, and verifies whether it is occupied , if it has been occupied, give the corresponding prompt

2. Connect to the SMS platform and send the verification code according to the generated random number combination

3. Delete the verification code cache under this number

4. Add the verification code cache under this number

5. Ajax obtains two passwords and compares them. If they are inconsistent, a corresponding prompt is given

6. Verify whether the verification codes are consistent

7. If the passwords are consistent, execute registration, jump to the home page, and delete the current mobile phone number verification code cache

Image:

Common function implementation processes in PHP development

3. Third-party login (qq, WeChat, Weibo, coding.net, Baidu, github, etc.)

The process of each third-party login platform is similar. Here is the introduction of qq third-party login

1. Obtain the app_id, app_key, and callback address from the qq developer platform

2. Splice request url

3. The request carries the state value to prevent CSRF attacks. The callback page will be returned as is

4. Process the callback and verify whether the returned state value is consistent with the local state value

5. If the state values ​​are consistent, then obtain accsess_token based on the returned code value

6. Get openid and user information based on accsess_token (on third-party platforms, each QQ number corresponds to a unique openid)

7. Perform local login registration operation based on openid

For example (determine whether the user is a new user of the website based on openid. If it is a new user, execute the registration process within the website and generate a corresponding uid, and then write the uid into the session or cookie to maintain the session. If the openid already exists, perform the login operation and directly write the uid corresponding to the openid into the session or cookie to maintain the session).

For more PHP related knowledge, please visit

PHP Tutorial!

The above is the detailed content of Common function implementation processes in PHP development. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete