How to Change to Sha1
#1

hi friends.. i need help with pcp website in login.php, this pcp use WP_Hash whirlpool, but my gamemodes use sha1.
i want change this login.php to sha1 password, i already change it, but dont work.. can help?



PHP код:

<?php
    session_start
();
    include 
"koneksi.php";
    if(isset(
$_SESSION['playername']))
    {
        
go('index.php''You already logged in.');
    }
    if(!isset(
$_POST['username'], $_POST['password']))
    {
        
go('index.php''Please fillout all required forms.');
    }
    else
    {
        
$query $koneksi->prepare("SELECT `level`,`name` from `player` where `name` = ? and `password` = ?");
        
$query->execute(array($_POST['username'], strtoupper(hash("whirlpool"$_POST['password']))));
        if(
$query->rowCount() > 0)
        {
            
$data $query->fetch();
            
go('index.php''Succesfully logged in.');
            
$_SESSION['playername'] = $data['name'];
            
$_SESSION['playerlevel'] = $data['level'];
        }
        else
        {
            
go('index.php''Wrong username or password.');
        }
    }
Reply
#2

http://php.net/manual/en/function.sha1.php

here you go
PHP код:
<?php 
    session_start
(); 
    include 
"koneksi.php"
    if(isset(
$_SESSION['playername'])) 
    { 
        
go('index.php''You already logged in.'); 
    } 
    if(!isset(
$_POST['username'], $_POST['password'])) 
    { 
        
go('index.php''Please fillout all required forms.'); 
    } 
    else 
    { 
        
$query $koneksi->prepare("SELECT `level`,`name` from `player` where `name` = ? and `password` = ?"); 
        
$query->execute(array($_POST['username'], strtoupper(sha1($_POST['password']))); 
        if(
$query->rowCount() > 0
        { 
            
$data $query->fetch(); 
            
go('index.php''Succesfully logged in.'); 
            
$_SESSION['playername'] = $data['name']; 
            
$_SESSION['playerlevel'] = $data['level']; 
        } 
        else 
        { 
            
go('index.php''Wrong username or password.'); 
        } 
    }
        else 
        { 
            
go('index.php''Wrong username or password.'); 
        } 
    }
Reply
#3

ahh nice... thanks
Reply
#4

bro.. i have erors

Parse error: parse error in C:\xampp\htdocs\cnr\check.php on line 15

PHP код:
$query->execute(array($_POST['username'], strtoupper(sha1($_POST['password']))); 
Reply
#5

You might have a problem when users try to login, since their old password is still whirlpool hashed, you have to force all users to set a new password. Also, why did u switch to sha1 instead of SHA256?
Reply
#6

try now

PHP код:
<?php  
    session_start
();  
    include 
"koneksi.php";  
    if(isset(
$_SESSION['playername']))  
    {  
        
go('index.php''You already logged in.');  
    }  
    if(!isset(
$_POST['username'], $_POST['password']))  
    {  
        
go('index.php''Please fillout all required forms.');  
    }  
    else  
    {  
        
$query $koneksi->prepare("SELECT `level`,`name` from `player` where `name` = ? and `password` = ?");  
        
$query->execute(array($_POST['username'], sha1($_POST['password'])));  
        if(
$query->rowCount() > 0)  
        {  
            
$data $query->fetch();  
            
go('index.php''Succesfully logged in.');  
            
$_SESSION['playername'] = $data['name'];  
            
$_SESSION['playerlevel'] = $data['level'];  
        }  
        else  
        {  
            
go('index.php''Wrong username or password.');  
        }  
    } 
        else  
        {  
            
go('index.php''Wrong username or password.');  
        }  
    }
Reply
#7

Quote:
Originally Posted by Yaa
Посмотреть сообщение
try now

PHP код:
<?php  
    session_start
();  
    include 
"koneksi.php";  
    if(isset(
$_SESSION['playername']))  
    {  
        
go('index.php''You already logged in.');  
    }  
    if(!isset(
$_POST['username'], $_POST['password']))  
    {  
        
go('index.php''Please fillout all required forms.');  
    }  
    else  
    {  
        
$query $koneksi->prepare("SELECT `level`,`name` from `player` where `name` = ? and `password` = ?");  
        
$query->execute(array($_POST['username'], sha1($_POST['password'])));  
        if(
$query->rowCount() > 0)  
        {  
            
$data $query->fetch();  
            
go('index.php''Succesfully logged in.');  
            
$_SESSION['playername'] = $data['name'];  
            
$_SESSION['playerlevel'] = $data['level'];  
        }  
        else  
        {  
            
go('index.php''Wrong username or password.');  
        }  
    } 
        else  
        {  
            
go('index.php''Wrong username or password.');  
        }  
    }
worked!! tahanks man
+1rep
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)