Whirlpool Login script

05/21/2012 17:08 Regen.#1
Hey,

Ich bin neu hier und suche ein Login Script mit Whirlpool hashing. Ich habe wenig ahnung von PHP. Das Script soll für minecraft sein. [Only registered and activated users can see links. Click Here To Register...]Ich brauche NUR ein Login script dafür die User registrieren sich ingame. Wenn es noch jemand machen würde hätte ich das gerne so, dass man wenn man sich einloggt abgefragt wird welchen status der Account hat. Und je nach status auf eine andere seite weitergeleitet wird.

Spaltennamen:


playername
password
accounttype


bei Accounttype gibt es user, moderator, admin, owner



Vielen Dank

Regen.
05/21/2012 18:31 Mikesch01#2
PHP Code:
<?php
function encryptWhirlpool($password) {
    
$salt substr(hash('whirlpool'uniqid(rand(), true)), 012);
    
$hash hash('whirlpool'$salt $password);
    
$saltPos = (strlen($password) >= strlen($hash) ? strlen($hash) : strlen($password));
    return 
substr($hash0$saltPos) . $salt substr($hash$saltPos);
}

//MySQL hier verbinden! 
$connection mysql_connect('host''benutzername''passwort');
mysql_select_db('datenbank'$connection);
$table 'Tabelle'

//Login
if(isset($_POST['login'])) {
$user mysql_real_escape_string($_POST['user']);
$password mysql_real_escape_string($_POST['password']);
$passwordCrypted encryptWhirlpool($password);

$query mysql_query("SELECT * FROM ".$table." WHERE playername = '".$user."'");
$row mysql_fetch_assoc($query);

if(empty(
$user) or empty($password)) {
  echo 
"Daten nicht vollständig!";
}
elseif(
$user == $row['playername'] && $passwordCrypted == $row['password']) {
  switch(
$row['accounttype']) {
    case 
'user'header("Location: seite1.php");
    case 
'moderator'header("Location: seite2.php");
    case 
'admin'header("Location: seite3.php");
    case 
'owner'header("Location: seite4.php");
  }
}
else {
  echo 
"Daten nicht korrekt!";
}

}
?>

<form method="post" action="">
Benutzername: <input type="text" name="user" /><br />
Passwort: <input type="text" name="password" /><br />
<input type="submit" name="login" value="login" />
</form>
Aus der Hand mal gezaubert...noch nicht selber getestet.
05/21/2012 19:12 Regen.#3
Erstmal VIELEN VIELEN DANK! Und nochmals Danke, dass du geantwortet hast egal ob es nicht funktioniert!

€dit: ich habe jetzt soweit alles konfiguriert doch :

Das hier erscheint im Webbrowser:
Code:
Parse error: syntax error, unexpected T_IF in E:\xampp\htdocs\Minecraft\logintest\login.php on line 15
Hier nochmal das script:

PHP Code:
<?php
function encryptWhirlpool($password) {
    
$salt substr(hash('whirlpool'uniqid(rand(), true)), 012);
    
$hash hash('whirlpool'$salt $password);
    
$saltPos = (strlen($password) >= strlen($hash) ? strlen($hash) : strlen($password));
    return 
substr($hash0$saltPos) . $salt substr($hash$saltPos);
}

//MySQL hier verbinden! 
$connection mysql_connect('localhost''root''tjawarwolnix :p');
mysql_select_db('minecraftserver'$connection);
$table 'accounts'

//Login
if(isset($_POST['login'])) {
$user mysql_real_escape_string($_POST['user']);
$password mysql_real_escape_string($_POST['password']);
$passwordCrypted encryptWhirlpool($password);

$query mysql_query("SELECT * FROM ".$table." WHERE playername = '".$user."'");
$row mysql_fetch_assoc($query);

if(empty(
$user) or empty($password)) {
  echo 
"Daten nicht vollständig!";
}
elseif(
$user == $row['playername'] && $passwordCrypted == $row['password']) {
  switch(
$row['accounttype']) {
    case 
'user'header("Location: seite1.php");
    case 
'moderator'header("Location: seite2.php");
    case 
'admin'header("Location: seite3.php");
    case 
'owner'header("Location: seite4.php");
  }
  }
}
else {
  echo 
"Daten nicht korrekt!";
}

}
?>

<form method="post" action="">
Benutzername: <input type="text" name="user" /><br />
Passwort: <input type="text" name="password" /><br />
<input type="submit" name="login" value="login" />
</form>
05/22/2012 16:49 Mikesch01#4
oh, da hatte ich ein ';' vergessen^^

hier berichtigt:
PHP Code:
<?php
function encryptWhirlpool($password) {
    
$salt substr(hash('whirlpool'uniqid(rand(), true)), 012);
    
$hash hash('whirlpool'$salt $password);
    
$saltPos = (strlen($password) >= strlen($hash) ? strlen($hash) : strlen($password));
    return 
substr($hash0$saltPos) . $salt substr($hash$saltPos);
}

//MySQL hier verbinden! 
$connection mysql_connect('localhost''root''tjawarwolnix :p');
mysql_select_db('minecraftserver'$connection);
$table 'accounts';

//Login
if(isset($_POST['login'])) {
$user mysql_real_escape_string($_POST['user']);
$password mysql_real_escape_string($_POST['password']);
$passwordCrypted encryptWhirlpool($password);

$query mysql_query("SELECT * FROM ".$table." WHERE playername = '".$user."'");
$row mysql_fetch_assoc($query);

if(empty(
$user) or empty($password)) {
  echo 
"Daten nicht vollständig!";
}
elseif(
$user == $row['playername'] && $passwordCrypted == $row['password']) {
  switch(
$row['accounttype']) {
    case 
'user'header("Location: seite1.php");
    case 
'moderator'header("Location: seite2.php");
    case 
'admin'header("Location: seite3.php");
    case 
'owner'header("Location: seite4.php");
  }
  }
}
else {
  echo 
"Daten nicht korrekt!";
}

}
?>

<form method="post" action="">
Benutzername: <input type="text" name="user" /><br />
Passwort: <input type="text" name="password" /><br />
<input type="submit" name="login" value="login" />
</form>