php实现用户注册密码的crypt加密
网络编程 2021-07-05 08:23www.168986.cn编程入门
这篇文章主要为大家详细介绍了php实现用户注册密码的crypt加密,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了php用户注册密码的加密,供大家参考,具体内容如下
一、代码
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://.w3./TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://.w3./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 "请认真填写用户名和密码!";//提示输入用户名和密码 } ?>
二、运行结果
注册成功后,数据库显示如下:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持狼蚁SEO。
上一篇:php面向对象的用户登录身份验证
下一篇:php封装一个异常的处理类
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程