[Tool/Web/Other] [PHP] PHP/HTML Masters Help!
#1

Hello, I am working on my webpage for my server and use a lot of Mysql. One of feature is login on webpage using your in-game username and password. Passwords are hashed in pawno using md5, and I guess it should be also in my php login sctipt. But how? I tried like this but it is still returning me Invalid password. Here is my PHP password:

Код:
<?php
/*session_start();*/
$username = $_POST['username'];
$password = $_POST['password'];

if($username&&$password)
{
$connect = mysql_connect("non", "non", "non") or die ("Couldn't connect!");
$selectdb = mysql_select_db("non") or die ("Couldn't select database!");
$query = mysql_query("SELECT * FROM users WHERE Username='$username'");
$numrows = mysql_num_rows($query);

if($numrows!=0)
{
  //check for login
  while($row = mysql_fetch_assoc($query))
  {
    $dbusername = $row['Username'];
    $dbpassword = $row['Password'];
  }
  //check if the match!
  if($username==$dbusername&&md5($password)==$dbpassword)
  {
     $_SESSION['username']=$username;
     echo $row['Username'];
     $query1 = mysql_query("SELECT * FROM users WHERE Username='$username'");
     $assoc = mysql_fetch_assoc($query1);
     echo "Welcome <b>".$assoc['Username']."</b>";
     echo "<p>";
     echo "<br>";
     echo "You currently have <b>".$assoc['Kills']."</b> kills and <b>".$assoc['Deaths']."</b> deaths.";
     echo "<br>";
     echo "<p>";
     if($assoc['Admin Level'] == 1)
     {        
       echo "You are <b>Moderator!</b>";
     }
     if($assoc['Admin Level'] == 2)
     {        
       echo "You are <b>Administrator!</b>";
     }
     if($assoc['Admin Level'] == 3)
     {
       echo "You are <b>Server Owner!</b>";
     }
     if($assoc['VIP'] == 1)
     {
       echo "<br>";
       echo "<p>";
       echo "You are <b>VIP Member!</b>";
     }
     echo "<br>";
     echo "<p>";
     echo "<a href='logout.php'>Logout!</a>";
     if($assoc['Admin Level'] == 0)
     {
       echo "<br>";
       echo "<p>";
       echo "<a href='ModeratorApplications.php'>Moderator Applications</a>";
     }
     if($assoc['Admin Level'] == 3)
     {
       echo "<br>";
       echo "<a href='modadmin.php'>Look For New Moderator Applications!</a>";
     }
     if($assoc['Admin Level'] == 2)
     {
       echo "You are <b>Server Owner!</b>";
       echo "<br>";
       echo "<a href='modadmin.php'>Look For New Moderator Applications!</a>";
     }
  }
  else
    echo "Incorrect password!";
}
else
  die("That user doesn't exist!");
}
else
  die("Please enter and username and password!");
?>
Anyone know how to fix log in and hashing passwords in PHP?

Thanks!
Reply


Messages In This Thread
[PHP] PHP/HTML Masters Help! - by Ironboy500 - 18.05.2010, 16:06
Re: [PHP] PHP/HTML Masters Help! - by mamorunl - 18.05.2010, 18:41
Re: [PHP] PHP/HTML Masters Help! - by Ironboy500 - 22.05.2010, 09:41
Re: [PHP] PHP/HTML Masters Help! - by Ironboy500 - 23.05.2010, 11:05
Re: [PHP] PHP/HTML Masters Help! - by GTA_Rules - 23.05.2010, 14:45
Re: [PHP] PHP/HTML Masters Help! - by saiberfun - 23.05.2010, 14:56
Re: [PHP] PHP/HTML Masters Help! - by mamorunl - 23.05.2010, 15:07
Re: [PHP] PHP/HTML Masters Help! - by Silent314 - 23.05.2010, 17:36
Re: [PHP] PHP/HTML Masters Help! - by Silent314 - 23.05.2010, 23:38
Re: [PHP] PHP/HTML Masters Help! - by Silent314 - 24.05.2010, 01:57

Forum Jump:


Users browsing this thread: 1 Guest(s)