This article is mainly for everyone to introduce the PHP implementation of user registration password crypt encryption, with a certain reference value, interested in small partners can refer to
This example for everyone to share the PHP user Registration password encryption, for your reference, the specific content as follows
One, the code
1, conn.php
<?php $conn = mysql_connect ("localhost", "root", "111") or Die ("Connection to database server failed!") ". Mysql_error ()); Connect MySQL server mysql_select_db ("Db_database21", $conn); Select Database Db_database21 mysql_query ("Set names UTF8"); Set the database encoding format UTF8?>
2, index.php
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
3, index_ok.php
<?php Header ("Content-type:text/html;charset=utf-8");//load header information include ("conn/conn.php");//contains database connection file if (Trim ($_post[' user '])! = "" and Trim ($_post[' pwd '])! = "") {//To determine if the input is empty $pwd = crypt ($_post[' pwd '], "key");// Crypt encryption for the entered password $sql = "INSERT into Tb_user (Username,password) VALUES ('". $_post[user]. "', '". $pwd. "')"; /define SQL statement $result = mysql_query ($sql, $conn);//Execute SQL statement if ($result) { echo "<font color= ' Red ' > registered successfully. </font> ";//If the result is true prompt registration successful }else{ echo" <font color= ' green ' > Registration failed!</font> ";//otherwise prompt registration failed } } else{ echo "Please fill in the user name and password carefully!" ";//Prompt for user name and password }?>
Ii. Results of operation
After successful registration, the database appears as follows: