重新哈希sha512密码? [英] re-hash sha512 password?

查看:92
本文介绍了重新哈希sha512密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HY!

我有一个问题需要重新哈希sha512密码。以下是我的注册和登录代码..



这是注册码。



HY!
i have a problem to re-hash a sha512 password. below is my code for registration and login..

this is the Registration code.

<?php
include 'conn.php';
$user=$_POST['username'];
$pass=$_POST['password'];
$pass=hash("sha512", $pass);

$sql="INSERT INTO user(USER_NAME,PASSWORD)VALUES('$user','$pass')";

$result=mysql_query($sql);
if($result)
{
    echo "record inserted";
}
else
{
    echo mysql_error();
}
//}
mysql_close($con);
?>







这是登录代码..






this is the login code..

<pre lang="php"><?php
include 'conn.php';
$user=$_POST['username'];
$pass=$_POST['password'];
$sel="SELECT * FROM user WHERE USER_NAME='".$user."' AND PASSWORD='".hash("sha512",$pass)."'";
$result=mysql_query($sel);
if(mysql_affected_rows() > 0)
{
        $row = mysql_fetch_object($result);

        $_SESSION["username"] = $row->USER_NAME;
        $_SESSION["password"]  = $row->PASSWORD;
      echo  header("location:index.php");
        }

       else
       {
        echo "user does'nt exist please<a href='signup.html'> signup</a> first";

       }
?>





问题是else语句在登录页面中执行..注册页面工作正常但登录页面不能..?

请检查...



谢谢..



the proble is that the else statement is executed in login page.. registration page working perfectly but login page can't..?
please check it...

THANK's..

推荐答案

user =


_POST [' 用户名'];
_POST['username'];


pass =


这篇关于重新哈希sha512密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆