A little php help with login.php
#1

Hi there, I would just use some help with the login.php, I'm pretty sure everything is alright but it won't log me in saying Wrong username or password.

Here's the code of login.php
PHP код:
<?php 
include 'includes/config.php';
if(isset(
$_SESSION['playername']))
{
    echo 
'<META HTTP-EQUIV="Refresh" Content="0; URL=index.php">';   
    exit;
}
if(isset(
$_POST['pname']) && isset($_POST['ppass']))
{
    if(!isset(
$_SESSION['playername']))
    {
        
$query $con->prepare("SELECT `name`, `regi_id` from `players` where `name` = ? and `pass` = ?");
        
$query->execute(array($_POST['pname'], strtoupper(hash("whirlpool"$_POST['ppass']))));
        if(
$query->rowCount() > 0)
        {
            
$data $query->fetch();
            
            
$_SESSION['playername'] = $data['name'];
            
$_SESSION['uID'] = $data['reg_id'];
            
            echo 
'<META HTTP-EQUIV="Refresh" Content="0; URL=index.php">';   
            exit;
            
            
        }
        else
        {
            
$err 'Wrong username or password';
        }
    }
}
 
include 
'includes/header.php';
?>
   <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            Login with your in-game account
                        </div>
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-6">
                                    
                                    <form action="login.php" method="POST">
                                        <div class="form-group">
                                            <label>Username</label>
                                            <input type="text" id="pname" name="pname" class="form-control" placeholder="Username">
                                        </div>
                                        <div class="form-group">
                                            <label>Password</label>
                                            <input type="password" id="ppass" name="ppass" class="form-control" placeholder="Password">
                                        </div>
                                        <?php if(isset($err)): ?>
                                        <b class="help-block" style="color: red;"><?=$err?></b>
                                        <?php endif; ?>
                                        
                                        <button type="submit" class="btn btn-default">Login</button>
                                    </form>
                                        
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>
    
<?php
include 'includes/footer.php'
?>
Probably the thing is that the passwords in the MySQL database are hashed. Could I unhash them somehow? And how could I fix this...
Reply


Messages In This Thread
A little php help with login.php - by iKevin - 21.04.2017, 20:43
Re: A little php help with login.php - by Jstylezzz - 21.04.2017, 21:01
Re: A little php help with login.php - by iKevin - 21.04.2017, 21:16
Re: A little php help with login.php - by Jstylezzz - 22.04.2017, 08:12
Re: A little php help with login.php - by iKevin - 22.04.2017, 11:00
Re: A little php help with login.php - by iKevin - 22.04.2017, 16:24
Re: A little php help with login.php - by Jstylezzz - 22.04.2017, 19:53

Forum Jump:


Users browsing this thread: 1 Guest(s)