I am trying to figure out why the PHP will not check the database level and echo the proper message. Hopefully someone can help me figure this out.
<?php
$connect = mysql_connect("localhost","goforgol_master","!rach22*") or die("Couldn't connect!");
mysql_select_db("goforgol_phplogin") or die("Couldn't find database");
session_start();
$email = $_POST['email'];
$password = $_POST['password'];
if ($email&&$password)
{
$query = mysql_query("SELECT * FROM users WHERE email='$email'");
$numrow = mysql_num_rows($query);
if ($numrow!=0)
{
// code to login
while ($row = mysql_fetch_assoc($query))
{
$dbemail = $row['email'];
$dbpassword = $row['password'];
$dbname = $row['name'];
$dblevel = $row['level'];
}
if ($email==$dbemail&&md5($password)==$dbpassword)
{
if ($dblevel==0)
{
echo "You are logged in! <a href='http://www.wordpresswealth.com/index.php'>Click</a> here purchase a membership package";
$_SESSION['email']=$email;
session_destroy();
}
elseif ($dblevel==1)
{
echo "You are logged in! <a href='http://www.wordpresswealth.com/Member_Library_Trial.php'>Click</a> here to enter Member's Library";
$_SESSION['email']=$email;
}
elseif ($dblevel==2)
{
echo "You are logged in! <a href='Member_Library.php'>Click</a> here to enter members page.";
$_SESSION['email']=$email;
}
elseif ($dblevel==3)
{
echo "You are logged in! <a href='Member_Library_Gold.php'>Click</a> here to enter members page.";
$_SESSION['email']=$email;
}
}
else
echo "Username or Password is incorrect";
}
else
die('Username or Password is incorrect');
}
else
die("Please enter a username and a password");
?>
Thanks in advance for any help.