我的数据库名称密码中有一个列,我只想在发布到数据库之前对密码进行散列或加密。我的 php 提交文件中有这样的代码。
<?php
session_start();
include('config.php');
$ID=$_POST['ID'];
$name=$_POST['name'];
$password=$_POST['password'];
$department=$_POST['department'];
$email=$_POST['email'];
$ID_arr=array();
$name_arr=array();
$password_arr=array();
$dept_arr=array();
$email_arr=array();
$i = -1;
++$i;
$ID_arr[$i]= $_POST['ID'];
$name_arr[$i]= $_POST['name'];
$password_arr[$i]= $_POST['password'];
$dept_arr[$i]= $_POST['department'];
$email_arr[$i]= $_POST['email'];
$j=0;
while ( $j <= $i)
{
$ID = $ID_arr[$i];
$name = $name_arr[$i];
$password = $password_arr[$i];
$department = $dept_arr[$i];
$email = $email_arr[$i];
$sql = "INSERT INTO `employee`. `admin` (ID ,name ,password ,department
,email) VALUES (
'$ID' ,'$name' ,'$password' ,'$department' ,'$email'
)";
$result = mysql_query($sql);
if(!$result){
die('invalid query:'.mysql_error());
}
else
echo ("<tr><td>" . "You have been succesfully registered..." . "</td></tr>");
header('Refresh:5; url=adminlogin.php');
die;
}
?>
我可以知道应该把加密功能放在哪里吗?或者有什么方法可以加密密码?