最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php實現(xiàn)用戶注冊密碼的crypt加密

 更新時間:2017年06月08日 10:22:29   作者:cakin24  
這篇文章主要為大家詳細介紹了php實現(xiàn)用戶注冊密碼的crypt加密,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了php用戶注冊密碼的加密,供大家參考,具體內容如下

一、代碼

1、conn.php

<?php 
  $conn = mysql_connect("localhost", "root", "111") or die("連接數(shù)據(jù)庫服務器失?。?.mysql_error()); //連接MySQL服務器 
  mysql_select_db("db_database21",$conn);     //選擇數(shù)據(jù)庫db_database21 
  mysql_query("set names utf8");           //設置數(shù)據(jù)庫編碼格式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>&nbsp;</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");//包含數(shù)據(jù)庫連接文件 
  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);//執(zhí)行sql語句 
    if($result){ 
      echo "<font color='red'>注冊成功。</font>";//如果結果為真提示注冊成功 
    }else{ 
      echo "<font color='green'>注冊失敗!</font>";//否則提示注冊失敗 
    } 
  }else{ 
    echo "請認真填寫用戶名和密碼!";//提示輸入用戶名和密碼 
  } 
?>  

二、運行結果

注冊成功后,數(shù)據(jù)庫顯示如下:

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

最新評論

宁都县| 新邵县| 新巴尔虎左旗| 淮北市| 遂平县| 南江县| 洛扎县| 景东| 深水埗区| 固始县| 修文县| 保康县| 龙海市| 馆陶县| 尖扎县| 靖远县| 紫阳县| 吉首市| 招远市| 射阳县| 平遥县| 弥渡县| 兴义市| 南陵县| 临夏县| 光泽县| 唐海县| 巴南区| 连云港市| 梅河口市| 历史| 汤阴县| 昌图县| 砚山县| 唐河县| 合作市| 乌拉特中旗| 东乡族自治县| 大足县| 鲜城| 闸北区|