Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Use php to create a database exercise, register

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Saturday, December 31, 2016

First, open XAMPP and create a folder under htdocs for php to create a database:

Second, prepare to create the necessary folders:

3. Open the folder with submit and view it on the left:

Create a php file under the config folder, db.config.php, write database links, database creation, database selection:

Four (2), open the Navicat for mysql software, click on the right side of diablo,F5 refresh

You can see the success of the creation.

Fourth (3). The data for creating the data table is prepared in advance, and the class table, guanliyuan table and person table are created with Navicat for mysql software.

Create (register) regist.html files under the admin folder, and (administrator)

Administrator.php file. Create a table to connect to the administrator.php file

,:

6. The effect of opening it with a browser after completion is shown in the figure:

7. Write the key steps in the (administrator) administrator.php file

Verify the regular expressions of the user name, password, and secondary password, and use the if function to determine:

To make the code clear, the distribution operates:

1. In the code, echo outputs username (user name), password (password) and repassword (reconfirm password). And set the $variables $name, $pass, $zaicipass,

Note: the trim function removes the white space at the beginning and end of the string.

2.$pat is a regular expression that verifies the validity of a user name. I set it to start with 3 to 6 digits with uppercase and lowercase letters, end with 0-9 numbers, and end with 3 to 18.

3.$repat is a regular expression that verifies the validity of a password twice. The rules are the same as above.

8. First of all, it is judged that the user name cannot be empty and the format is incorrect:

Note: the empty () function is used to test whether the variable has been configured. Returns a false value if the variable already exists, a non-empty string, or a non-zero; otherwise, true.

If $name is empty, the echo content is output. Header jumps back to the registration page regist.html.

Add the code that is not executed by the die () function.

The preg_match function is used for regular judgment, else if (! preg_match ($pat,$name))

If the $name format does not conform to the $pat regular, then echo "user name format error"

The effect of the header,die function is as above.

9. Verify the password format:

Note: the preg_match function is used for regular judgment if (! preg_match ($repat,$pass))

Then echo "password format is incorrect"

Else if ($passwords, passwords and passwords

Echo "two passwords are inconsistent"

The effect of header,die function is the same as above.

Enter and reference database files:

Note: the guanliyuan table in Navicat for mysql is introduced here, so use the

Insert into guanliyuan . And set a variable $userdata for it.

Md5 is used to encrypt passwords.

To make a judgment:

Note: mysql_query function query link:

The mysql_error function displays an error message.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report