What is the principle of registering the login function of PHP website?

Source: Internet
Author: User
Tags oauth php mysql php website
Can you introduce me? I want to make a website.

Reply content:

    • Registered
      • Status judgment: If it is logged in (through cookie authentication), the page jumps to the homepage of the website, otherwise the registration page is displayed.
      • Form filling: Front page A form, mainly including the mailbox, password, duplicate password, verification code and so on.
      • The front-end judgment format: through the JS regular expression to determine whether the mailbox conforms to the mailbox format, the password conforms to certain length and the difficulty and so on.
      • Determine if it is registered: Ajax determines whether the mailbox has been registered and, if so, prompts to log in;
      • Form submission: Post form.
      • Background judgment format: Prevent the front-end JS is modified or directly post data, need to verify the data format in the background.
      • Insert a database: Insert information about the new user into the database (password needs to be encrypted, not clear), and return the user ID of the new user if the data in the form is correct.
      • Jump to login status: The user ID and other information to the user to add a cookie to keep their login status.
    • Login
      • Status judgment: If it is logged in, the page jumps to the homepage of the website, otherwise the login page is displayed.
      • Form Fill: The front-end a form, including the mailbox and password.
      • The front-end judgment format: Determine whether the mailbox conforms to the mailbox format, password compliance length and so on.
      • Form submission: Post form.
      • Background match: Finds whether the user exists, matches the user's password, and returns whether it matches.
      • Page Jump: If the match succeeds, add the cookie to keep the login status, otherwise prompt the related error, and jump back to login status.

Comments @ Zhong Yunlong Daoist supplement:
1. Email Verification
For most sites that use a mailbox as an ID, a verification URL is usually sent to verify that you are the owner of the message (in fact, it is not necessary), the basic principle is simple, add 2 fields to the user table: A randomly generated verification code and a validation status. The verification code is included in the URL sent by the mailbox.

2. OAuth
OAuth is currently an agreement to register and sign in with a third-party account, and the latest version is OAuth 2.0. The most commonly used three-party account is Weibo and QQ, foreign is Google, Facebook and so on. Before using them, you need to make a request for the account, get Appkey and Appsecret, set the redirect Uri, and sometimes need to download the relevant SDK for a series of configurations to use. / http blog.xuite.net/gotrans/ life/13801477-php+-+php+session+%e4%bd%bf%e7%94%a8%e5%85%a5%e9%96%80
[PHP] Use sessions and cookies to keep logged in (remember me) status function
Log in to the admin, PHP MySQL
https:// Books.google.com.hk/boo ks?id=_afwbqaaqbaj&pg=sa9-pa38&lpg=sa9-pa38&dq=php+%e7%99%bb%e5%85%a5+%e5%ae%89%e5%85%a8& Source=bl&ots=tghluhmsns&sig=g_znfgmmgjtd9mqahjaaf1vnaq8&hl=zh-tw&sa=x&ei= Aiojvdwddspymgxj2ycabq&ved=0ceoq6aewbzgk#v=onepage&q=php%20%e7%99%bb%e5%85%a5%20%e5%ae%89%e5%85%a8 &f=false
http://codepen.io/
http://denghao.me/
http://www.w3schools.com/
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.