2014-10-21 3 views
0

구현 혼란 여기 내가 가지고있는 코드입니다, 그러나 Bcrypt 사용하여 해시 암호에 올 때 나는 혼란 스러워요 : 로그인 버튼을 제출 클릭 여기 는 Bcrypt

<?php 
session_start(); 
include_once('bcrypt.php'); 

$db_host = 'localhost'; 
$db_user = ''; 
$db_pass = ''; 
$db_name = 'credentials'; 

if (!isset($_POST['userName'])) 
{ 
    echo 'You did not enter a valid username.'; 
    exit; 
} 

if (!isset($_POST['pass'])) 
{ 
    echo 'You did not enter a valid password.'; 
    exit; 
} 

$con = new mysqli($db_host, $db_user, $db_pass, $db_name); 
if ($con->connect_error) 
{ 
    die('Connect Error (' . $con->connect_errno . ') ' . $con->connect_error); 
} 

$sql = "SELECT userName, pass FROM `Members` WHERE userName = ?"; 
if (!$result = $con->prepare($sql)) 
{ 
    die('Query failed: (' . $con->errno . ') ' . $con->error); 
} 

if (!$result->bind_param('s', $_POST['userName'])) 
{ 
    die('Binding parameters failed: (' . $result->errno . ') ' . $result->error); 
} 

if (!$result->execute()) 
{ 
    die('Execute failed: (' . $result->errno . ') ' . $result->error); 
} 

$result->store_result(); 
if ($result->num_rows == 0) 
{ 
    die('There is no such username in our database.'); 
} 

$result->bind_result($db_username, $db_password); 
$result->fetch(); 
$result->close(); 
$con->close(); 

$bcrypt = new Bcrypt(15); 
if ($bcrypt->verify($pass, $db_password)) 
{ 
    $_SESSION['userName'] = $db_username; 
    header('location:index.html'); 
    exit; 
} 
else 
{ 
    echo 'Incorrect username or password.'; 
} 

가 난 후지고있어 오류입니다 :

Warning: include_once(bcrypt.php): failed to open stream: No such file or 
directory in C:\Users\Julian Buscema\Desktop\Subpost.me\htdocs\connectivity- 
login.php on line 3 
Warning: include_once(): Failed opening 'bcrypt.php' for inclusion 
(include_path='.;C:\Users\Julian Buscema\Desktop\Subpost.me\php\PEAR') in 
C:\Users\Julian Buscema\Desktop\Subpost.me\htdocs\connectivity-login.php on line 3 
You did not enter a valid username. 

나는 belcrypt.php가 빠졌지 만 Bcrypt로 일한 적이 없으므로 여기에서 어디로 가야할지 잘 모르겠습니다.

+0

bcrypt가 PHP로 이미 구현되었습니다 –

+0

@self 그래서 오류가 의미 할 수있는 것은 무엇입니까? 내가 게시 한 코드는 연결에 대한 login.php입니다. –

답변

0

bcrypt.php이 루트 디렉토리에없는 파일이므로, Bcrypt이 이미 PHP로 구현되어 있고 대신 함수를 사용할 수 있기 때문에 Bcrypt을 사용할 필요가 없습니다.

+0

위에 게시 한 파일은 connectivity-login.php이지만 내 connectivity-login.php를 온라인으로 찾았 기 때문에 bcrypt.php 파일이 누락되었습니다.하지만 편집했습니다. –

+0

나는 당신이 무엇을 의미하는지에 대해 확신하지 못한다. 기본적으로 내가 달성하고자하는 것은 로컬 MySQL 서버를 사용하는 레지스터 및 로그인 시스템이다. 등록 기능을 완료하고 이름 "credential"아래에 "fullname", "userName", "email"및 "pass"테이블을 작성하지만 지금 로그인 섹션을 작성하려고합니다. –

+0

어디서나 bcrypt.php 파일을 찾을 수 없습니다. 내 서버의 루트 폴더에 들어가서 PHP, 배, PEAR, Crypt로 갔지만 어디서나 bcrypt.php를 찾을 수 없습니다 :/ –