Help with UCP
#1

Hi, i am editing one UCP but i cant login with the password which i am registering from IG.
I am hashing my passwords with md5 and i can only login with the hashed password so i tryed a way to hash the password which player enters when he wants to login with the password which is already hashed in the database, but i cant get it to work
Can any PHP expert help me solve this problem?
PHP код:
$submit   $_POST['submit']; 
$logout   $_POST['logout']; 
$username sanitize($_POST['Name']); 
$password sanitize($_POST['Password']);
$rawInput sanitize($_POST["password"]);
$hashedInput hash("md5"$rawInput); 
if(
$submit)
{
    if(!
strcmp($password$hashedInput)) 
    {
        if(
$username && $password)
        {
            
$query mysql_query("SELECT * FROM `players` WHERE `Name` = '$username' AND `Password` = '$password'");
            if(
mysql_num_rows($query) == 1
            {
                while(
$row mysql_fetch_assoc($query)) 
                {
                    
$dbusername $row['Name']; 
                    
$dbpassword $row['Password']; 
                }
                if(
$username == $dbusername && $password == $dbpassword
                {
                    
setcookie("Name"$dbusernametime()+60*60*24*365*20);
                    
$_SESSION['Name'] = $dbusername
                    
header('Location: index.php');
                }
                else echo 
"<script>alert('You have to enter password!');</script>";
            }
        }
    }

Reply
#2

HEy, how about doing this instead,

$hashedInput = md5($_POST['password']);
sanitize function COULD'VE removed some character in the inputbox, you should just let it accept everything since its a password.. or echo the results so you can check on what happened..
Reply
#3

Still not works. Any other opinions?
Reply
#4

PHP код:
$query mysql_query("SELECT * FROM `players` WHERE `Name` = '$username' AND password = md5('$password')" 
Try that.
Reply
#5

Quote:
Originally Posted by DanishHaq
Посмотреть сообщение
PHP код:
$query mysql_query("SELECT * FROM `players` WHERE `Name` = '$username' AND password = md5('$password')" 
Try that.
The md5() function in SQL generates a lowercase hash whilst the md5 include generates a higher case hash. -That may be your problem. Try and only use the md5() function in queries inside the gamemode.
Reply
#6

Arlight so how to hash this so i can compare the dbpassword with the password which i enter at the login box :
PHP код:
$dbpassword $row['Password']; 
Reply
#7

PHP код:
//password = md5($password);
if($submit)
{
    if(
$username && $password)
    {    
        
$query mysql_query("SELECT * FROM `players` WHERE `Name` = '$username' AND `Password` = '$password'"); 
        if(
mysql_num_rows($query) == 1
        {
            while(
$row mysql_fetch_assoc($query)) 
            {
                
$dbusername $row['Name']; 
                
$dbpassword $row['Password']; 
                
//$dbpassword = md5($dbpassword);
            
}
            if(
$username == $dbusername && $password == $dbpassword
            {
                
setcookie("Name"$dbusernametime()+60*60*24*365*20);
                
$_SESSION['Name'] = $dbusername
                
header('Location: index.php');
            }
            else echo 
"<script>alert('You have to enter password!');</script>";
        }
    }

Tryed like this but it still doesnt works...
Reply
#8

This forum isn't for php help =/
Reply
#9

Quote:
Originally Posted by [ABK]Antonio
Посмотреть сообщение
This forum isn't for php help =/
Actually, this particular topic regards to samp scripting so I'm she it's fine.
Reply
#10

He* and yes its related about samp scripting so i need to solve this asap.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)