Tråd bedømmelse:
  • 0 Stemmer - 0 Gennemsnit
  • 1
  • 2
  • 3
  • 4
  • 5
[PHP] Login sha
07-05-2016, 12:35
#1
[PHP] Login sha
Hej!
Er ved at lave et mindre website for en til en game server men databasen har sha hashed passwords. Nu er jeg ikke den store php koder når det kommer til kryptering osv. Men hvordan søren skal jeg matche passworded med et sha password? Måske lidt nedern  at skulle skrive et sha password for at logge ind xD

Min kode:

Kode:
<?php

$user_username = "";

if (isset ($_POST['submit_login']))
{
$user_username = $_POST['username'];
$user_password = $_POST['sha_pass_hash'];

$errormsg = "";

// ==============================================================

// Validér formulardata

if ($user_username == "")
{
$errormsg .= "Insert username<br />";
}

if ($user_password == "")
{
$errormsg .= "Insert password<br />";
}

// ==============================================================

if ($errormsg == "")
{

$query = "SELECT * FROM account
 WHERE username = '$user_username'
 AND   sha_pass_hash = '$user_password'";

$result = mysqli_query ($db_link, $query) or die (mysqli_error ($db_link));

$antal = mysqli_num_rows ($result);

if ($antal == 1)
{
$row = mysqli_fetch_assoc ($result);

$_SESSION['user_id']       = $row['id'];
$_SESSION['user_username'] = $row['username'];

header ('Location: index.php');
exit;
}
else
{
$errormsg .= "Forkert brugernavn eller password";
}
}
}
?>

<?php
// ==============================================================
if (isset ($errormsg) && $errormsg != "")
{
echo "<div id='errormsg'>$errormsg</div>";
}
// ==============================================================
?>
<div id="loginsection">
    <div class="menubg">
        <p class="menufont">Login</p>
    </div>
<div id="loginarea">
        <form id="loginform" method="POST">
        <input id="username" placeholder="Username" type="text" name="username" />
        <input id="password" placeholder="Password" type="password" name="sha_pass_hash" />
        <input id="loginbutton" type="submit" value="Login" name="submit_login" />
        </form>
</div>
</div>
Explore the world we must
Time's just to short for the best of us
Before death comes
Find alle beskeder fra denne bruger
Citer denne besked i et svar
« Ældre | Nyere »


Beskeder i denne tråd
[PHP] Login sha - af Henta24 - 07-05-2016, 12:35
RE: [PHP] Login sha - af s0x - 07-05-2016, 12:43
RE: [PHP] Login sha - af Henta24 - 07-05-2016, 12:50
RE: [PHP] Login sha - af Doctor Blue - 07-05-2016, 12:52
RE: [PHP] Login sha - af s0x - 07-05-2016, 12:56
RE: [PHP] Login sha - af Henta24 - 07-05-2016, 12:53
RE: [PHP] Login sha - af Henta24 - 07-05-2016, 13:02
[PHP] Login sha - af s0x - 07-05-2016, 13:04
RE: [PHP] Login sha - af Henta24 - 07-05-2016, 13:12
RE: [PHP] Login sha - af s0x - 07-05-2016, 13:21
RE: [PHP] Login sha - af Henta24 - 07-05-2016, 13:25
RE: [PHP] Login sha - af s0x - 07-05-2016, 13:25
RE: [PHP] Login sha - af Henta24 - 07-05-2016, 13:30
RE: [PHP] Login sha - af s0x - 07-05-2016, 13:31
RE: [PHP] Login sha - af Ash - 07-05-2016, 16:03
RE: [PHP] Login sha - af s0x - 07-05-2016, 17:59
RE: [PHP] Login sha - af Ash - 07-05-2016, 18:34
RE: [PHP] Login sha - af s0x - 07-05-2016, 19:19
RE: [PHP] Login sha - af Ash - 07-05-2016, 19:23
RE: [PHP] Login sha - af Doctor Blue - 08-05-2016, 15:30
RE: [PHP] Login sha - af Ash - 08-05-2016, 17:34
RE: [PHP] Login sha - af Doctor Blue - 08-05-2016, 20:11
RE: [PHP] Login sha - af Ash - 08-05-2016, 20:39
RE: [PHP] Login sha - af Henta24 - 07-05-2016, 22:21
RE: [PHP] Login sha - af dagGi - 09-05-2016, 17:27
RE: [PHP] Login sha - af Ash - 09-05-2016, 21:54



User(s) browsing this thread: 1 Gæst(er)