Php registration and login interface implementation case (recommended), login interface case
At the beginning, I thought that the registration and login functions on a website were amazing. Later I did some research and found that the reason was very simple. Next I would like to see how to implement it ....
I have created several files on my computer:
Login.html (logon page)
Register.html (registration page)
Success.html (logon successful jump page)
Return.html (registration successful page)
Login. php
Register. php
Success.html does not
What are some html tags:
<Html>
<Html>
Return.html is the page displayed after registration, which contains a piece of js code used to regularly return to the logon interface.
<Html>
Register. php this is the background page corresponding to the registration page
<? Php $ link = mysql_connect ("localhost", "root", "207207"); // link the database header ("Content-type: text/html; charset = UTF-8 "); if ($ link) {// echo "connected to the database succeeded"; $ select = mysql_select_db ("login", $ link); // select the database if ($ select) {// echo "Database Selected! "; If (isset ($ _ POST [" sub "]) {$ name = $ _ POST [" username "]; $ password1 = $ _ POST ["password"]; // obtain form data $ password2 = $ _ POST ["password2"]; if ($ name = "" | $ password1 = "") // you can specify {echo "<script type = ". "\"". "text/javascript ". "\"". "> ". "window. alert ". "(". "\"". "please fill it out! ". "\"". ")". ";". "</Script>"; echo "<script type = ". "\"". "text/javascript ". "\"". "> ". "window. location = ". "\"". "http: // 127.0.0.1: 8080/register.html ". "\"". "</script>"; exit;} if ($ password1 = $ password2) // confirm that the password is correct {$ str = "select count (*) from register where username = ". "'". "$ name ". "'"; $ result = mysql_query ($ str, $ link); $ pass = mysql_fetch_row ($ result); $ pa = $ pass [0]; if ($ pa = 1) // determine whether the user name {echo "<script t already exists in the Database Table Ype = ". "\"". "text/javascript ". "\"". "> ". "window. alert ". "(". "\"". "This user name has been registered ". "\"". ")". ";". "</script>"; echo "<script type = ". "\"". "text/javascript ". "\"". "> ". "window. location = ". "\"". "http: // 127.0.0.1: 8080/register.html ". "\"". "</script>"; exit;} $ SQL = "insert into register values (". "\"". "$ name ". "\"". ",". "\"". "$ password1 ". "\"". ")"; // insert registration information into the database table // echo "$ SQL"; mysql_query ($ SQL, $ link); mysql_query ('set NAMES Utf8'); $ close = mysql_close ($ link); if ($ close) {// echo "database closed"; // echo "registered successfully! "; Echo" <script type = ". "\"". "text/javascript ". "\"". "> ". "window. location = ". "\"". "http: // 127.0.0.1: 8080/return.html ". "\"". "</script>" ;}}else {echo "<script type = ". "\"". "text/javascript ". "\"". "> ". "window. alert ". "(". "\"". "inconsistent passwords! ". "\"". ")". ";". "</Script>"; echo "<script type = ". "\"". "text/javascript ". "\"". "> ". "window. location = ". "\"". "http: // 127.0.0.1: 8080/register.html ". "\"". "</script>" ;}}}}?>
Login. php logon interface corresponding to background files
<? Php header ("Content-type: text/html; charset = UTF-8"); $ link = mysql_connect ("localhost", "root", "207207 "); if ($ link) {$ select = mysql_select_db ("login", $ link); if ($ select) {if (isset ($ _ POST ["subl"]) {$ name = $ _ POST ["usernamel"]; $ password = $ _ POST ["passwordl"]; if ($ name = "" | $ password = "") // determines whether it is null {echo "<script type = ". "\"". "text/javascript ". "\"". "> ". "window. alert ". "(". "\"". "Please fill in the correct information! ". "\"". ")". ";". "</Script>"; echo "<script type = ". "\"". "text/javascript ". "\"". "> ". "window. location = ". "\"". "http: // 127.0.0.1: 8080/login.html ". "\"". "</script>"; exit;} $ str = "select password from register where username = ". "'". "$ name ". "'"; mysql_query ('set NAMES utf8'); 20 $ result = mysql_query ($ str, $ link); $ pass = mysql_fetch_row ($ result ); $ pa = $ pass [0]; if ($ pa = $ password) // determine whether the password is consistent with the password at registration {echo "Logon successful! "; Echo" <script type = ". "\"". "text/javascript ". "\"". "> ". "window. location = ". "\"". "http: // 127.0.0.1: 8080/success.html ". "\"". "</script>" ;}{ echo "<script type = ". "\"". "text/javascript ". "\"". "> ". "window. alert ". "(". "\"". "Logon Failed! ". "\"". ")". ";". "</Script>"; echo "<script type = ". "\"". "text/javascript ". "\"". "> ". "window. location = ". "\"". "http: // 127.0.0.1: 8080/login.html ". "\"". "</script>" ;}}}}?>
There are still many things to improve when you are idle. You are welcome to ask questions and discuss them and provide a simpler method!
The above is all the php registration and login interface implementation cases (recommended) provided by the editor. I hope you can provide more support to the customer's home ~