21.04.2017, 20:43
(
Последний раз редактировалось iKevin; 22.04.2017 в 16:31.
)
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
Probably the thing is that the passwords in the MySQL database are hashed. Could I unhash them somehow? And how could I fix this...
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';
?>