


The example of this article shares the encryption of phpuser registration password for your reference. The specific content is as follows
1. Code
1、conn.php
<?php $conn = mysql_connect("localhost", "root", "111") or die("连接数据库服务器失败!".mysql_error()); //连接MySQL服务器 mysql_select_db("db_database21",$conn); //选择数据库db_database21 mysql_query("set names utf8"); //设置数据库编码格式utf8 ?>
2、index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>用户注册</title> <style type="text/css"> <!-- body,td,th { font-size: 12px; } --> </style></head> <body> <form id="form1" name="form1" method="post" action="index_ok.php"> <fieldset style="width:500px"><legend style="font-size:16px">用户注册</legend><table width="300" border="0" align="center"> <tr> <td width="77" align="right">用户名:</td> <td width="213"><input name="user" type="text" id="user" size="24" /></td> </tr> <tr> <td align="right">密码:</td> <td><input name="pwd" type="password" id="pwd" size="25" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="sub" value="注册" /> <input type="reset" name="res" value="重置" /></td> </tr> </table></fieldset> </form> </body> </html>
3、index_ok.php
<?php header("content-type:text/html;charset=utf-8"); //加载头信息 include("conn/conn.php");//包含数据库连接文件 if(trim($_POST['user'])!= "" and trim($_POST['pwd'])!= ""){//判断输入是否为空 $pwd = crypt($_POST['pwd'],"key");//对输入的密码进行crypt加密 $sql = "insert into tb_user(username,password)values('".$_POST[user]."','". $pwd."')";//定义sql语句 $result = mysql_query($sql,$conn);//执行sql语句 if($result){ echo "<font color='red'>注册成功。</font>";//如果结果为真提示注册成功 }else{ echo "<font color='green'>注册失败!</font>";//否则提示注册失败 } }else{ echo "请认真填写用户名和密码!";//提示输入用户名和密码 } ?>
二、 Running results
After successful registration, the database displays as follows:
The above is the detailed content of How does php crypt implement encryption of user registration passwords?. For more information, please follow other related articles on the PHP Chinese website!

如何使用PHP和CGI实现用户注册和登录功能用户注册和登录是许多网站必备的功能之一。在本文中,我们将介绍如何使用PHP和CGI来实现这两个功能。我们将通过代码示例来演示整个过程。一、用户注册功能的实现用户注册功能允许新用户创建一个账户,并将其信息保存到数据库中。以下是实现用户注册功能的代码示例:创建数据库表首先,我们需要创建一个数据库表,用于存储用户信息。可

如何用PHP实现CMS系统的用户注册/登录功能?随着互联网的发展,CMS(ContentManagementSystem,内容管理系统)系统成为了网站开发中非常重要的一环。而其中的用户注册/登录功能更是不可或缺的一部分。本文将介绍如何使用PHP语言实现CMS系统的用户注册/登录功能,并附上相应的代码示例。以下是实现步骤:创建用户数据库首先,我们需要建立一

如何利用PHP函数实现用户注册和登录的验证码生成和验证?在网站的用户注册和登录页面中,为了防止机器人批量注册和攻击,通常需要添加验证码功能。本文将介绍如何利用PHP函数实现用户注册和登录的验证码生成和验证。验证码生成首先,我们需要生成随机的验证码图片供用户填写。PHP提供了GD库和图像处理函数,可以方便地生成验证码图片。<?php//创建一个画布

十大加密货币交易平台包括:1. OKX,2. Binance,3. Gate.io,4. Kraken,5. Huobi,6. Coinbase,7. KuCoin,8. Crypto.com,9. Bitfinex,10. Gemini。选择平台时应考虑安全性、流动性、手续费、币种选择、用户界面和客户支持。

使用Laravel框架实现用户注册和登录功能的步骤Laravel是一个流行的PHP开发框架,提供了许多强大的功能和工具,使得开发者可以轻松构建各种Web应用程序。用户注册和登录是任何应用程序的基本功能之一,下面我们将使用Laravel框架来实现这两个功能。步骤1:创建新的Laravel项目首先,我们需要在本地计算机上创建一个新的Laravel项目。打开终端或

如何利用PHP函数实现用户注册和登录?在Web开发中,用户注册和登录是非常常见的功能。PHP作为一种流行的服务器端脚本语言,提供了丰富的函数和工具来帮助我们实现这些功能。在本文中,我们将学习如何使用PHP函数来实现用户注册和登录功能。首先,我们需要创建一个数据库来存储用户的信息。我们可以使用MySQL数据库,通过以下代码创建一个名为"users"的表:CRE

如何使用PHP开发用户注册和登录系统随着互联网的普及和发展,用户注册和登录系统已经成为了几乎所有网站和应用程序的必备功能。本文将介绍如何使用PHP开发一个简单的用户注册和登录系统,并提供代码示例供参考。一、数据库设计在开发用户注册和登录系统之前,我们先来设计数据库。假设我们需要保存用户的以下信息:用户名、密码、电子邮箱、注册时间等。首先,创建一个名为user

标题:PHP实现用户注册时发送手机验证码详解导语:用户注册时发送手机验证码是一种常见的安全验证方式,本文将详细介绍如何使用PHP实现用户注册时发送手机验证码的功能,并提供具体的代码示例。一、注册流程概述在开始编写具体的代码之前,我们需要对注册流程进行概述。用户注册时发送手机验证码的基本流程如下:用户填写注册信息,包括手机号码和其他必要的信息。用户点击发送验证


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor
