如何使用河豚登录

时间:2015-07-30 09:47:30

标签: php login blowfish

当我想要注册并且我的通行证被哈希时,我的河豚是好的,但现在我有使用哈希密码登录的问题。当我尝试使用常规密码登录时,它没问题,但是当我尝试使用哈希密码登录时,我得到一个空白页面!

这是我的注册页面:

include "/inc/common.inc";
require_once("function.php");

$db_link = db_connect();
$username = $_POST["username"];
$password = $_POST["password"];
$ime = $_POST["firstname"];
$prezime = $_POST["lastname"];  
$email = $_POST["email"];
$adresa = $_POST["adress"];



$algo = '$2a$10$';

$salt = uniqid('', true);   

$hash = crypt($password, $algo . $salt);    
$new_hash = crypt($password, $algo . $salt);
$password = $new_hash;


$query1 = "select * FROM clanovi where password = 'password'";
$result1 = mysql_query($query1, $db_link);
$row = mysql_fetch_row($result1);

if ($row[0]) {
    $koriniskPostoji = "Podatci o korisniku vec postoje";
    header("Location: unos_kupca.php?obavestenje=$koriniskPostoji");
} else {
    $set_password = $row['password'];
    //$input_password = crypt($password, $set_password);
    $link =  "login_form.php";
    $query1 = "insert into clanovi (username, password, ime, prezime, email, adresa) VALUES 
                ('$username', '$password', '$ime', '$prezime', '$email', '$adress')";

        }
    $result1 = mysql_query($query1, $db_link);
    header("Location: $link");

这是我的登录代码,问题是当我输入密码时,它与我的数据库中的密码不同。例如,对于密码" ceca18"在我的数据库密码是" $ 2a $ 10 $ 55b79dc175242"当我以登录形式加密并回显它时,密码结果为" $ 2a $ 10 $ 55b9fa6a14cce6.655217u9GC57hawJckzLbM0BRD5dVzFVALmwAi"。我不知道如何解决它,所以如果你有一些想法的帮助!

include "/inc/common.inc";

$servername = "localhost";
$username = "root";
$password = "";

$conn = new mysqli($servername, $username, $password);

session_start();
$korisnik = $_POST["Username"];
$password = $_POST["password"];

$algo = '$2a$10$';

$salt = uniqid('', true);   

$hash = crypt($password, $algo . $salt);    
$new_hash = crypt($password, $algo . $salt);
//$new_hash = $password;

if (crypt($password, $algo . $salt) == $password) {
    $db_link = db_connect();
$query ="select * from CLANOVI WHERE username = '$korisnik' AND password = '$password' ";

$result = mysql_query($query, $db_link);
$row_clanovi = mysql_fetch_array($result);

if ($row_clanovi[0] == null) {
    $pogresniPodaci = "Podaci su pogresno uneti ili niste registrovani";
    //header("Location: login.php?pogresniPodaci=$pogresniPodaci");

}
else {
    $set_password = $row['password'];
    //$input_password = crypt($password, $set_password);
    $link = "index.html";
header("Location: sign_up.php");

}
}
else{
    echo "Can't work";
    //echo $password;
    echo "<br>";
    echo $new_hash;
}

0 个答案:

没有答案