December 2016 31, Saturday
First, open the XAMPP, create a folder under Htdocs for PHP to create the database:
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/8C/44/wKioL1hnwBGhh7uhAAM5hYResrE707.png-wh_500x0-wm_3 -wmp_4-s_995447636.png "title=" 2016-12-28_170504.png "alt=" Wkiol1hnwbghh7uhaam5hyresre707.png-wh_50 "/>
Second, prepare to create the necessary folders:
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/8C/44/wKioL1hnwSmgpqLlAAHr10KAefk605.png-wh_500x0-wm_3 -wmp_4-s_2842796946.png "title=" 2016-12-31_223014.png "alt=" Wkiol1hnwsmgpqllaahr10kaefk605.png-wh_50 "/>
Open folder with Submit, view on the left:
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/8C/48/wKiom1hnwYuQo_OmAAIzO5sBqUY659.png-wh_500x0-wm_3 -wmp_4-s_1776832783.png "title=" 2016-12-31_223123.png "alt=" Wkiom1hnwyuqo_omaaizo5sbquy659.png-wh_50 "/>
iv. Create a php file under the Config folder, db.config.php, write a database link, database creation, database selection:
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/8C/44/wKioL1hnw2jx-G6eAAIzfLTKfLc437.png-wh_500x0-wm_3 -wmp_4-s_3557068820.png "title=" 2016-12-31_224015.png "alt=" Wkiol1hnw2jx-g6eaaizfltkflc437.png-wh_50 "/>
Four (2), open navicat for MySQL software, click on the right diablo,f5 refresh
Create success can be seen.
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/8C/44/wKioL1hnxvLDcx9pAABC6z24vok635.png-wh_500x0-wm_3 -wmp_4-s_575632583.png "title=" 2016-12-31_225525.png "alt=" Wkiol1hnxvldcx9paabc6z24vok635.png-wh_50 "/>
Four (3), pre-prepared data to create the data table, with Navicat for MySQL software created class table, Guanliyuan table, Person table:
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/8C/48/wKiom1hnx-GAwv8_AAEZEiAbyIY175.png-wh_500x0-wm_3 -wmp_4-s_2399154847.png "title=" 2016-12-31_225918.png "alt=" Wkiom1hnx-gawv8_aaezeiabyiy175.png-wh_50 "/>
V. Create (register) the regist.html file under the Admin folder, and ( Admin)
administrator.php file. Create a <from> table to connect to the administrator.php file
, <form action= "./administrator.php" method= "POST";:
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/8C/44/wKioL1hnxO6A9CyHAAIP5Y3pOjI746.png-wh_500x0-wm_3 -wmp_4-s_2254596344.png "title=" 2016-12-31_224655.png "alt=" Wkiol1hnxo6a9cyhaaip5y3poji746.png-wh_50 "/>
Six, after the completion of the browser open effect
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/8C/48/wKiom1hnxVXwXzwtAAC2VdxPvP0659.png-wh_500x0-wm_3 -wmp_4-s_3158642949.png "title=" 2016-12-31_224803.png "alt=" Wkiom1hnxvxwxzwtaac2vdxpvp0659.png-wh_50 "/>
Vii. key steps, write separately in the (admin)administrator.php file
A regular expression that validates the user name, password, two times password, and uses the IF function to determine:
To make the code clear, the distribution operates:
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/8C/44/wKioL1hnyVmiCGX2AAI2c_-OnfI064.png-wh_500x0-wm_3 -wmp_4-s_3627360854.png "title=" 2016-12-31_230540.png "alt=" Wkiol1hnyvmicgx2aai2c_-onfi064.png-wh_50 "/>
1. In the code, ECHO output username (username), password (password), Repassword (re-confirm password). and set the $ variable $name, $pass, $zaicipass,
Note: The trim function removes whitespace from the end of the string.
2. $pat a regular expression to verify the validity of the user name, I set it to start with the uppercase and lowercase letters 3 to 6 bits, ending with 0-9 digits, 3 to 18.
3.$repat A regular expression that verifies the validity of two passwords, as in the rule above.
Eight, first of all to determine the user name cannot be empty, format error:
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/8C/48/wKiom1hny8qSiEtGAAHev-rc_sk023.png-wh_500x0-wm_3 -wmp_4-s_3141011310.png "title=" 2016-12-31_231535.png "alt=" Wkiom1hny8qsietgaahev-rc_sk023.png-wh_50 "/>
Note: the empty () function is used to test whether a variable has been configured. Returns a value of False if the variable already exists, a non-empty string, or nonzero, and returns true instead.
If $name is empty, the echo content is output. Header jumps back to the registration page regist.html.
Adding the die () function does not execute after the code.
The Preg_match function is used for regular judgment, else if (!preg_match ($pat, $name))
echo "User name format error" If $name format does not conform to $pat
The Header,die function works as above.
Nine, verify the password format:
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/8C/48/wKiom1hnzuPQQz5eAAHkbmJaH_M121.png-wh_500x0-wm_3 -wmp_4-s_3996861951.png "title=" 2016-12-31_232841.png "alt=" Wkiom1hnzupqqz5eaahkbmjah_m121.png-wh_50 "/>
Note: the preg_match function is used for regular judgment if (!preg_match ($repat, $pass))
The echo "password format is incorrect"
else if ($pass! = $zaicipass) Determine if the password is consistent two times, if inconsistent
echo "Two times password Inconsistent"
The Header,die function works as above.
Ten, warehousing, reference database files:
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/8C/48/wKiom1hn0HzQ3J8FAAHM_izGx48930.png-wh_500x0-wm_3 -wmp_4-s_1592431105.png "title=" 2016-12-31_233454.png "alt=" Wkiom1hn0hzq3j8faahm_izgx48930.png-wh_50 "/>
Note: The Guanliyuan table in Navicat for MySQL is introduced here, so use the
INSERT INTO Guanliyuan. and set a variable $userdata for it.
The MD5 is used to encrypt the password.
To judge:
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/8C/48/wKiom1hn0nzRIRCeAAHqHVW7JQ8188.png-wh_500x0-wm_3 -wmp_4-s_4090595830.png "title=" 2016-12-31_234345.png "alt=" Wkiom1hn0nzrirceaahqhvw7jq8188.png-wh_50 "/>
Note: mysql_query function Query Link:
The Mysql_error function displays an error message.
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/8C/44/wKioL1hn1EbRj5JzAADdAac0Lrg669.png-wh_500x0-wm_3 -wmp_4-s_719271592.png "title=" 2016-12-31_235224.png "alt=" Wkiol1hn1ebrj5jzaaddaac0lrg669.png-wh_50 "/>
Create database exercises with PHP, register