Home  >  Article  >  Backend Development  >  PHP+javascript implements user registration module (source code attached)

PHP+javascript implements user registration module (source code attached)

烟雨青岚
烟雨青岚forward
2020-06-09 10:42:334467browse

PHP+javascript implements user registration module (source code attached)

php javascript implements user registration module (source code attached)

1. Function introduction

Use language: html + javascript ajax php

Backend database: MySQL

(* There is no style involved here )

Successful registration process:

① Registration page (register.html), this page provides a form to collect user information.

② After submission, go to the register.php page and use php to add the registration information to the database.

2. Implementation code

(1) Create the user information table in the MySql database

Requirements:Create user information table:

Code:

CREATE TABLE xxx_user(
  uid INT PRIMARY KEY AUTO_INCREMENT,
  uname VARCHAR(32),
  upwd VARCHAR(32),
  email VARCHAR(64),
  phone VARCHAR(16),
  gender INT     #性别  0-女  1-男
);

(2) HTML page layout code

Requirements: Create a register.html (non-ajax) and provide the following controls (form)——

● Login name-text box

● Login Password - password box

● Confirm password - password box

● User email - email

● Contact information - text box

● User gender - Drop-down box

● Registration button

Code

登录名称:

登录密码:

确认密码:

电子邮箱:

手机号码:

用户性别:

(3) Create register.php

Requirements: ① In init.php, encapsulate the reused connection database

The code is as follows:

Requirements: ② Receive the data submitted by register.html, insert it into the database, and then give a prompt

The code is as follows:

(4) JavaScript code

Requirements:① Encapsulate functions that can be reused

The code is as follows:

Requirements: ② Implement the function of verifying the repeatability of user names and the consistency of two passwords on the front-end page

The code is as follows:


(5) PHP code to verify whether the user name is repeated

Function: Accept the uname value from the front end, query whether the same name exists in the database, and Give the return prompt

The code is as follows:

Thank you for reading, I hope you can benefit from reading the code.

This article is reproduced from: https://blog.csdn.net/weixin_38840741/article/details/80030792

Recommended tutorial: "PHP Tutorial"

The above is the detailed content of PHP+javascript implements user registration module (source code attached). 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