Register password with md5

My password registration is in md5 format.
But on login :

<?php
session_start();
$host = "";
$username = "";
$password = "";
$db_name = "";
$tbl_name = "";
mysql_connect($host, $username, $password) or die("can't connect");
mysql_select_db($db_name) or die(mysql_error());
$username = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT * FROM $tbl_name WHERE username='$username' and password='$password'";
$result = mysql_query($sql);
$count = mysql_num_rows($result);
if($count==1) {
$userinfo = mysql_fetch_object($result);
  session_register("username");
  session_register("password");
  header("location:game.php?page=pokemons");
$_SESSION['id'] = $userinfo -> id;
$_SESSION['username'] = $userinfo -> username;
$_SESSION['level'] = $userinfo -> level;
}
else{
echo "";
}
?>

The password with md5 does not match, please tell me what needs to be corrected.


Answer 1, authority 100%

Beyond this line

   mysql_connect($host, $username, $password) or die("can't connect");

passing?

It’s not clear from the previous answers.

At this point, both username and password are empty lines (see not 5 lines above).


Answer 2

$sql = “SELECT * FROM $tbl_name WHERE username=’$username’ and password='”.md5($password).”‘”;

Let’s do this.
echo $sql; exit;
copy the request from your browser and run it from phpMyAdmin or whatever you are using.
if it does not give you a result – check the correctness of the login / password – are they really entered into the database.


Answer 3

It just doesn’t let you into the system, writes the wrong username or password!